It may seem like a duplicate, but it ain't.
I have 2 AutoCompleteTextView
's in my layout. From Address, To Address. I need to know which one of them initiated the drop down list.
Since both were using the same item layout, I duplicated it and tried, still no luck.
Initialization of AutoCompleteTextView
's
fromAutoComplete = new AutoComplete(this, R.layout.fromautocomplete);
fromAutoComplete.setNotifyOnChange(true);
fromAddress = (AutoCompleteTextView) findViewById(R.id.fromAddress);
fromAddress.setAdapter(fromAutoComplete);
fromAddress.setOnItemClickListener(this);
fromAddress.setOnItemSelectedListener(this);
toAutoComplete = new AutoComplete(this, R.layout.toautocomplete);
toAutoComplete.setNotifyOnChange(true);
toAddress = (AutoCompleteTextView) findViewById(R.id.toAddress);
toAddress.setAdapter(toAutoComplete);
toAddress.setOnItemClickListener(this);
toAddress.setOnItemSelectedListener(this);
Notice the R.layout.toautocomplete and R.layout.fromautocomplete
Both are identical as below.
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:minLines="3"
android:layout_marginBottom="15dp"
android:textSize="15dp"
android:text="sample text"
android:marqueeRepeatLimit="marquee_forever"/>
To debug the values, I have put some Log statements
@Override
public void onItemSelected(AdapterView<?> parent, View who, int position, long id) {
Log.e("Taxeeta", ">"+parent.getId()+":"+who.getId()+":"+id) ;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("Taxeeta", parent.getId()+":"+view.getId()+":"+id) ;
}
Output of log is
07-02 17:24:14.773: E/Taxeeta(12103): -1:-1:0
Frankly, this just sucks, why would id's for parent, view and id return such useless values ?
I am missing something really basic here.