I have two autocompletetextview the goal for example if any one select the autocompletetextview "HUB ID " position#3 then the another autocompletetextview " HUBName" must be forced to be on position 3 ie want the both of them at the same position
// HUB Name listener
HubName.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) {
HubName.setSelection(pos);
Log.d("ID Array follow pos","HUB ID in selected");
HubID.setSelection(pos);
HubName.setSelection(pos);
ShltrArray.clear();
ShltrArray.add(Shltr1Array.get(pos).toString());
if (Shltr2Array.get(pos).toString() != "Not")
{
ShltrArray.add(Shltr2Array.get(pos).toString());
}
ShltrAdapt.notifyDataSetChanged();
}
});
HubName.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
HubName.setSelection(position);
HubID.setSelection(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
HubName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HubName.showDropDown();
Log.d("ID Array follow ID ", Integer.toString(HubID.getListSelection()));
Log.d("ID Array follow Name ", Integer.toString(HubName.getListSelection()));
}
});
the solution to index the array list to the same position of the first array then inside autocompleteTextView listener then set text to this position as follow
HubName.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) {
HubID.setText(IDArray.get(pos).toString());}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.