My code works like this to list all items in my String array – itemsarray
setListAdapter(new ArrayAdapter<String>(this, R.layout.row,
R.id.label, itemsarray));
However, I know by this call that I only want to list the first X number of items from itemsarray. How can I load only the first X items form itemsarray into the ListAdapter?
There’s no way to do it automatically… you will have to do it manually. You have two alternatives:
Or you can create a subclass of
ArrayAdapterand override thegetCountmethod returning X. It will make the list think it just have X elements to show.