Autocompletetextview Stops Listening To Onitemclick
Existing code and xml The code fromAutoComplete = new AutoComplete( this, R.layout.fromautocomplete, R.id.fromautocomplete); fromAutoComplete.setNotifyOnChange(true
Solution 1:
Got it working,
Fixes
- Gave a
id
to myLinearLayout
- Used the layout
id
in myonItemClick
- Used
R.layout.<file>
in the constructor
XML (R.layout.fromautocomplete)
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/toautocompleteLayout"android:layout_width="fill_parent"android:layout_height="wrap_content" ><TextViewandroid:id="@+id/toautocomplete"
Code
fromAutoComplete = newAutoComplete(this,
R.layout.fromautocomplete,
R.id.fromautocomplete);
fromAutoComplete.setNotifyOnChange(true);
OnItemClick
@OverridepublicvoidonItemClick(AdapterView<?> parent, View view, int position,
long id) {
if (view.getId() == R.id.fromautocompleteLayout) {
Solution 2:
You need to get Textview from LinearLayout
@OverridepublicvoidonItemClick(AdapterView<?> parent, View view, int position, long id) {
Viewv= (TextView)((LinearLayout )view).getChildAt(0);
Strings= ((TextView) v).getText().toString();
//Do something with string s
}
Post a Comment for "Autocompletetextview Stops Listening To Onitemclick"