I'm having issues getting an item from a ListView when it is off screen. If I scroll down and hit next, the top item returns null. If I scroll back up, the bottom item return null.
I know ListView dynamically creates the view so is it possible to get items off screen?
public void onNextClick(View w){
Intent i = new Intent(this, homeActivity.class);
for(int position = 0; position < expandableLayoutListView.getAdapter().getCount(); position++)
{
try {
Hub temp = ((Hub) expandableLayoutListView.getAdapter().getItem(position));
System.out.println("Position " + position);
System.out.println("Other position " + (position - expandableLayoutListView.getFirstVisiblePosition()));
ExpandableLayoutItem expandableLayout = (ExpandableLayoutItem)
expandableLayoutListView.getChildAt(position - expandableLayoutListView.getFirstVisiblePosition())
.findViewWithTag(ExpandableLayoutItem.class.getName());
JoinedHub hub = new JoinedHub(temp.name);
if(((CheckBox) expandableLayout.findViewById(R.id.checkBox1)).isChecked())
hub.addToSubHubs( ((CheckBox) expandableLayout.findViewById(R.id.checkBox1)).getText().toString() );
if(((CheckBox) expandableLayout.findViewById(R.id.checkBox2)).isChecked())
hub.addToSubHubs(((CheckBox) expandableLayout.findViewById(R.id.checkBox2)).getText().toString());
if(((CheckBox) expandableLayout.findViewById(R.id.checkBox3)).isChecked())
hub.addToSubHubs(((CheckBox) expandableLayout.findViewById(R.id.checkBox3)).getText().toString());
Log.d("Debugging position", temp.getName() + " " + position);
if(!hub.subHubs.isEmpty()){
joinedHubs.add(hub);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Log.d("Debugginggg", joinedHubs.toString());
startActivity(i);
}