Created
January 13, 2017 01:47
-
-
Save fnzainal/90be8f39295e04fadfe2b007ffa38a90 to your computer and use it in GitHub Desktop.
untuk mengambil View pada item listview
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
/** | |
* untuk mencari posisi item pada listview | |
* @param position : posisi item pada listview | |
* @param listView : listview | |
* @return View posisi item | |
*/ | |
public static View getViewByPosition(int position, ListView listView) { | |
final int firstListItemPosition = listView.getFirstVisiblePosition(); | |
final int lastListItemPosition = firstListItemPosition | |
+ listView.getChildCount() - 1; | |
if (position < firstListItemPosition || position > lastListItemPosition) { | |
return listView.getAdapter().getView(position, null, listView); | |
} else { | |
final int childIndex = position - firstListItemPosition; | |
return listView.getChildAt(childIndex); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment