android - autoCompleteTextView using getText().toString() get the value is not in the array -


final string[] defaulttask1  = {"abc"," def"," ghi"}; final autocompletetextview autocompletetextview = (autocompletetextview)this.findviewbyid(r.id.autocompletetextview); arrayadapter<string> adapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1,defaulttask1); autocompletetextview.setthreshold(0); autocompletetextview.setadapter(adapter); 

i have method using autocompletetextview.gettext().tostring().while user types words not in array, may happen "null pointer exception"

is there solution can use autocompletetextview, can search user , let user enter text want?

p.s. sorry, i'm not native speaker, there might grammar mistake.

autocompletetextview right solution needs

an editable text view shows completion suggestions automatically while user typing. list of suggestions displayed in drop down menu user can choose item replace content of edit box with.

autocompletetextview allow user type whatever he/she want give suggestions array.

autocompletetextview.gettext().tostring() 

will not return null in case of user types words not in array. return whatever text there right in text view. might crash if gettext().tostring() on empty text view. have check before convert textview string

if(autocompletetextview.gettext()!=null) string textviewstring = autocompletetextview.gettext().tostring() 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -