Android Getting Object ID from List View?
I basically have 3 different objec开发者_StackOverflow中文版ts in my list view:
TextView1
TextView2
TextView3
I want to get the object ID from the list view that's created dynamically. Ex: How do I set TextView2 with a background image from a list view in position 1?
I've tried using
lv.getItemAtPosition(1);
This will return the whole row and I'm just looking for the object ID TextView2
inside lv.getItemAtPosition(1)
? Once I get the objectI
D from a certain position in list view, I can than change the TextView
2 background.
Sorry, if I didn't explain clear enough. Does anyone know what I'm talking about?
If you write about row, I assume something like that can work for you:
TableRow tableRow = lv.getItemAtPosition(1);
for (int i = 0; i < tableRow.getChildCount(); i++) {
View child = tableRow.getChildAt(i);
if ( child instanceof TextView ) {
TextView textView = (TextView) child;
textView.DO_SOMETHIG__WITH_TEXT_VIEV();
textView.requestLayout();
}
}
tableRow.requestLayout();
Of course if you have some other row than tableRow, you can try to change it to that type.
精彩评论