I have a baseadapter and it always starts at position 0 or 1 at the very top but is there someway that I can make my Baseadapter start at position 5? I been searching on here and have not found information on that, this is my baseadapter and yes it is connected to a listview but I know that the position that the listview starts is controlled by the BaseAdapter
public class myadapter extends BaseAdapter {
Context context;
LayoutInflater myiflater;
public myadapter() {
myiflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return 20;
}
@Override
public Object getItem(int position) {
return 5;
}
@Override
public long getItemId(int position) {
return 5;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// all of this is already correct
}
catch (Exception e) {
e.printStackTrace();
}
return convertView;
}
return convertView;
}
}
As you can see I have tried to set the starting position at 5 but it will not work.
Do this with your ListView:
mListView.setSelection(5);
setSelection() sets the current position of the ListView via the adapter. The way you are trying doesn't make sense. For the getItem() method you are supposed to return the object, not a numerical value for position. Let me know if that works