Reputation: 69
I'm trying to make my AutoCompleteTextView
variable called autoCategory_book
show all of its options just by pressing on the field.
// expected ')', expected ';', expected '(', expected '{', cannot resolve symbol 'view', cannot resolve symbol 'b' unexpected token
autoCategoty_book.setOnFocusChangeListener(View.OnFocusChangeListener(view , b -> if(b) autoCategory_book.showDropDown()));
string.xml
<string-array name="category_book">
<item> Self help </item>
<item> Biography </item>
<item> Education </item>
<item> Science fiction </item>
<item> Manual </item>
<item> Literature </item>
<item> Romance </item>
</string-array>
RegisterBook.java
protected void onCreate(Bundle savedInstanceState) {
AutoCompleteTextView autoCategory_book;
String[] Category_book;
Category_book = getResources().getStringArray(R.array.category_book);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, Category_book);
autoCategory_book.setThreshold(0);
autoCategory_book.setAdapter(adapter);
autoCategoty_book.setOnFocusChangeListener(View.OnFocusChangeListener(view , b -> if(b) autoCategory_book.showDropDown()));
}
Upvotes: 1
Views: 47
Reputation: 342
you don't need View.onFocusChangeListener
:
autoCategory_book.setOnFocusChangeListener((v, hasFocus) ->{
if(hasFocus){ autoCategory_book.showDropDown();
);
Upvotes: 1