android - AutoCompleteTextView Not Working Properly on adding data from Database -
i have autocompletetextview works fine when define string statically this..
private string names[] = {"hassan", "usman", "kristen stewart"};
then this..
arrayadapter<string> adapter = new arrayadapter<string> (this, android.r.layout.select_dialog_item, names); //getting instance of autocompletetextview catgnames.setthreshold(0);//will start working 0 character catgnames.setadapter(adapter);//setting adapter data autocompletetextview
but when try load data sqlite, drop down suggestion doesn't work. i'm doing this..
categories = new string[100] int =0; databasehandler db = new databasehandler(this); list<entries> entries1 = db.getcategories(); (entries cn : entries1) { log.i("", cn.getcategories()); names[i] = cn.getcategories(); i++; }
and after define adapter..
arrayadapter<string> adapter = new arrayadapter<string> (this, android.r.layout.select_dialog_item, names); //getting instance of autocompletetextview catgnames.setthreshold(0);//will start working 0 character catgnames.setadapter(adapter);//setting adapter data autocompletetextview
this doesn't work. there no error or warning in log-cat..
i wondering why pass categories in arrayadapter while adding values names[]? should 'names' instead of 'categories' in arrayadapter,
arrayadapter<string> adapter = new arrayadapter<string> (this, android.r.layout.select_dialog_item, names);
or can create list, add db column values , pass them in arrayadapter. hope helps!
Comments
Post a Comment