I'm trying to make my autoCategory_book
variable only allow changing the value change for the options provided by category_book
not allowing user input, the problem is that the field is closed for any change, leaving the value shown totally static for the change.
How do I authorize the autoCategory_book
to change to just the category_book
options, that's my question.
Got it, simulate a Spinner
in autoCategory_book
to change the current option to another option.
- The line blocking the field is this one, located in
BookAdapter.java
.
autoCategory_book.setKeyListener(null);
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>
BookAdapter.java
public class ViewHolder extends RecyclerView.ViewHolder{
AutoCompleteTextView autoCategory_book;
String[] Category_book;
public ViewHolder(@NonNull View itemView) {
super(itemView);
autoCategory_book = itemView.findViewById(R.id.autoCategory_book);
autoCategory_book.setKeyListener(null);
Category_book = itemView.getResources().getStringArray(R.array.category_book);
ArrayAdapter<String> adapter = new ArrayAdapter<>(itemView.getContext(),android.R.layout.simple_list_item_1, Category_book);
autoCategory_book.setThreshold(0);
autoCategory_book.setAdapter(adapter);
autoCategory_book.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
autoCategory_book.showDropDown();
}
});
}
}