If the ListView
only shows 5 items, and the all data is 40 items. How can I get the current selection is which position in visible items (1~5)? I have tried getSelectedItemPosition
but it will return the position in all data. I want the position number in visible items shows on each item.
class MyAdapter extends BaseAdapter {
@Override
public int getCount(){
...
}
@Override
public Object getItem(int position){
...
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
// I want to get the position number in visible items here
}
}
getFirstVisiblePosition()
can get first visible position in all items,so you can use getSelectedItemPosition()-getFirstVisiblePosition()
to make it.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments