-
-
Save RobGThai/4500764 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Update single item inside {@link ListView}. | |
* @param target {@link Object} object to update view. | |
*/ | |
private void refreshListItem(Object target){ | |
ListView list = getListView(); | |
// Find position of the first visible row | |
int start = list.getFirstVisiblePosition(); | |
// Find position of the last visible row | |
int end = list.getLastVisiblePosition(); | |
for(int i=start, j=end;i<=j;i++) { | |
if (target == list.getItemAtPosition(i)) { | |
// Target view to process | |
View view = list.getChildAt(i - start); | |
// Calling getView will redraw the whole item | |
View v = list.getAdapter().getView(i, view, list); | |
// Call requestLayout to update only certain item in the view | |
view.findViewById(R.id.image).requestLayout(); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment