I want to use AutoCompleteTextview for a list I have. I am using also an Adapter where I add the list. I want to print the element I click on. I use the following code but it does not work.
myAutoComplete.setOnItemClickListener(new OnItemClickListener() {
String selected;
boolean click = false;
public void onItemClick (AdapterView<?> parentView,View selectedItemView,int position, long id) {
//code
}
}
Also how to disable the ability to write in the AutoCompleteTextview? I don’t want to write anything. I just want to print a list and select an element from it (including the first element).
Here is the layout xml file.
<AutoCompleteTextView
android:id="@+id/myautocomplete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.95"
android:background="@android:color/black"
android:textColor="#FFFFFF" />
Any help is appreciated.
If you don’t want to write anything on
autoCompleteTextViewand select items, you have to implement theSPINNERis more greatput this on your xml file
in your code
after you can use