android - Empty ListView when EditText is empty -


i have code takes data sqlite cursor , puts listview.

private void displaylistview() {     cursor = mydatabase.getjoinedinfo(etsearch.gettext().tostring().trim());      string[] columns = new string[] { "re_value", "g_value", "ke_value" };      int[] = new int[] { r.id.tvhiragana, r.id.tvmeaning, r.id.tvkanji };      dataadapter = new simplecursoradapter(this, r.layout.wordonlist,             cursor, columns, to, 0);      listview listview = (listview) findviewbyid(r.id.lvwordlist);     // assign adapter listview      listview.setadapter(dataadapter); } 

when edittext empty, taking first 10 lines. how show empty listview when edittext empty?

do :

if(youredittext.length() == 0)     yourlistview.setadapter(null); 

or can use :

if(youredittext.length() == 0)     youradapter.clear(); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -