AndroidIOS

Get actual adapter position at Auto Complete TextView in Android

String selection = (String) parent.getItemAtPosition(position);
int pos = -1;

for (int i = 0; i < clientName.size(); i++) {
if (clientName.get(i).equals(selection)) {
pos = i;
break;
}
}
System.out.println("Position " + pos); //check it now in Logcat

As Like

      autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
                String selection = (String) parent.getItemAtPosition(position);
                int pos = -1;

                for (int i = 0; i < clientName.size(); i++) {
                    if (clientName.get(i).equals(selection)) {
                        pos = i;
                        break;
                    }
                }
                System.out.println("Position " + pos); //check it now in Logcat


           

                    
});
}

Leave a Reply

Your email address will not be published. Required fields are marked *

July 2020
M T W T F S S
« Apr   Sep »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Site Statistics

  • Users online: 0 
  • Visitors today : 6
  • Page views today : 6
  • Total visitors : 2,876
  • Total page view: 3,222