How to show the dropdown below EditText?

I have an EditText and one button for searching, now I want to show the list of search results below EditText when the button is clicked,

enter image description here

when I enter the text "abc" and click on the search button, then the dropdown should be open below the EditText.

An offer or sample demo or code is required.

Edit: it should open a drop-down menu that looks like an AutoCompleteTextView

+4
source share
4 answers

use AutocompleteTextView, set the "setTreshold ()" high and call showDropDown () when the button is clicked

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(); } }); 
+7
source

you can call ListView or Spinner when you click the search button .. and set the values ​​to adapter ...

+1
source

use the list view and install the adapter after clicking the button

0
source

an easy way to achieve this is

  • place the text image just below the search query, which will have a width as text to edit text and height.
  • set for it the text of the search result when you click
  • when the user again tries to put something in the search text, it should be cleared of the text representation
0
source

Source: https://habr.com/ru/post/1481946/


All Articles