I am trying to add listener that will react when an item is selected on the autocompletetextview...can anyone help //phonename is the autocompletetextview
Ph
try this:
phoneName.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View arg1, int pos,
long id) {
Toast.makeText(check.this," selected", Toast.LENGTH_LONG).show();
}
});
In kotlin, this would be:
autoCompleteTextView.setOnItemClickListener { _, _, position, _ ->
// You can get the label or item that the user clicked:
val value = adapter.getItem(position) ?: ""
Toast.makeText(this, value, Toast.LENGTH_LONG).show();
}
I also recommend you name your variables starting with a lowercase letter to not confuse them with types.