Android ListView: get data index of visible item

It's very easy. Just use ListView.getFirstVisiblePosition() + indexYouWant. For instance, to get the position in the adapter of the 2nd child displayed in the ListView, just use getFirstVisiblePosition() + 1.

No need for all the scary stuff shown in the reply above :)


listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
    public void onItemSelected(AdapterView<?> parent,View view, int pos, long id) 
    {
        AisleId= parent.getSelectedItemId();
    }
    @Override
    public void onNothingSelected(AdapterView<?> arg0) {
        // TODO Auto-generated method stub
    }
});

In this we will get list item Id parent.getSelectedItemId();