I have a EditText and one Button for Search, now i want to show list of search result below EditText when click on button,
when i enter text "abc" and click on search button then drop down should be open below EditText.
need suggestion or sample demo or code.
Edit: It should open drop down which seems like in AutoCompleteTextView
use AutocompleteTextView, set high treshold "setTreshold()" and call showDropDown() on button click
code update:
String[] values = {
"abc_0", "def_0", "ghi_0",
"abc_1", "def_1", "ghi_1",
"abc_2", "def_2", "ghi_2",
"abc_3", "def_3", "ghi_3",
};
final AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.actv);
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, values);
actv.setAdapter(adapter);
actv.setThreshold(256); // if not enough set Integer.MAX_VALUE
findViewById(R.id.button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
CharSequence constraint = actv.getText();
adapter.getFilter().filter(constraint);
actv.showDropDown();
}
});
you can call ListView
or Spinner
on click of search button.. and set values to its adapter
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With