Java – AutoCompleteTextView forces all items to be displayed

There was a time in my application when I had to force all items in the suggestion list to be displayed no matter what the user entered How can I do this?

I tried to do some filtering, but for me, beginner filtering is just too complicated. I tried to search beginner tutorials for filtering without any luck Perhaps there is a simpler way to force all suggested items to be displayed?

Editor: basically what's my idea? When a user enters something in the list, all available options will be displayed

I found the best way to check whether ACTV shows the weather, but ontextchangeevent compares the text entered by the user with my list, and then displays the complete list if no elements are found

public void onTextChanged(CharSequence s,int start,int before,int count)
         {                
           final EditText editText = (EditText) findViewById(R.id.vardsUserInput);
            String strValue = editText.getText().toString().toUpperCase();
            String temp;
            int Cc=0; //my count variable
            for(int i=0; i<vardi.length; i++)
            {
                temp = vardi[i].toUpperCase();
                if(temp.startsWith(strValue.toUpperCase()))
                {
                    Log.d("testing",vardi[i]);
                    Cc++;                                                   
                }
            }               
        if(Cc == 0)
        {
        //Show all the available options
    textView.showDropDown();                    
         }                  
}

Solution

When you want to display all the results, you don't define "time", so I hope this is suitable But try something like this:

AutoCompleteTextView autoComplete;
String savedText;

public void showAll() {
    savedText = autoComplete.getText().toString();
    autoComplete.setText("");
    autoComplete.showDropDown();
}

public void restore() {
    autoComplete.setText(savedText);
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>