AutoCompleteTextView OnItemClick position is always "0"
Don't ask me why, but the argument position
in method OnItemClickListener.onItemClick
holds the index relative to the AutoCompleteTextView
's dropdown list, not the position in your adapter array (in your case regions
)!
So, to find the item's real position
you must get the string selected in the dropdown and find its index in the adapter array:
String[] regions = ct.getRegions();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, regions);
regionT.setAdapter(adapter);
regionT.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String selected = (String) parent.getItemAtPosition(position);
int pos = Arrays.asList(regions).indexOf(selected);
}
});