java - Android Listview not refreshing -


hi program should update listview based on radiobutton selected , show records of 1 of 2 tables.

as far can tell records in fact populated, seems not refreshing listview itself. please me solve problem. in advance

here code:

in oncreate:

radiogroup rg = (radiogroup) findviewbyid(r.id.radiogroup1);         rg.setoncheckedchangelistener(new oncheckedchangelistener()         {             @override             public void oncheckedchanged(radiogroup group, int checkedid)             {                 radiobutton rb1 = (radiobutton) findviewbyid(r.id.radio0);                 radiobutton rb2 = (radiobutton) findviewbyid(r.id.radio1);                  switch(checkedid)                 {                 case r.id.radio0:                     {                         rb2.setchecked(false);           //                      populatelist(); //                      listview lview = (listview) findviewbyid(r.id.listview1); //                      lview.invalidateviews();                     }                     break;                 case r.id.radio1:                 {                         rb1.setchecked(false); //                      populatelist(); //                      listview lview = (listview) findviewbyid(r.id.listview1); //                      lview.invalidateviews();                 }                     break;                 }                 populatelist();   //              listview lview = (listview) findviewbyid(r.id.listview1); //              lview.updateviewlayout();             }           });    

methods used:

 private void populatelist()      {         radiobutton rb1 = (radiobutton) findviewbyid(r.id.radio0);         radiobutton rb2 = (radiobutton) findviewbyid(r.id.radio1);         edittext medit1 = (edittext)findviewbyid(r.id.edittext1);          list = new arraylist<hashmap>();         insertconstant();          if(rb1.ischecked() == true)         {              auditds = new projectauditingdatasource(this);                 auditds.open();                  list<datacapture> auditvalues = auditds.getallaudits();                 arrayadapter<datacapture> auditadapter = new arrayadapter<datacapture>(this,                         android.r.layout.simple_list_item_1, auditvalues);                  int countaudits = 0;                  int auditsize = auditvalues.size();                  while (countaudits < auditsize)                 {                     hashmap temp2 = new hashmap();                                temp2.put(first_column,auditvalues.get(countaudits).getid());                     temp2.put(second_column,auditvalues.get(countaudits).getname());                     temp2.put(third_column, auditvalues.get(countaudits).getxcoordinate());                                  temp2.put(fourth_column, auditvalues.get(countaudits).getvmstartdate());                      list.add(temp2);                     countaudits++;                 }          }             //////////////////////////////////////////////////////////////////////          if(rb2.ischecked() == true)         {             assetsds = new assetsdatasource(this);             assetsds.open();              list<assets> assetvalues = assetsds.getallassets();             arrayadapter<assets> assetadapter = new arrayadapter<assets>(this,                 android.r.layout.simple_list_item_1, assetvalues);              int countassets = 0;              int size = assetvalues.size();              while (countassets < size)             {                 hashmap temp = new hashmap();                             temp.put(first_column,assetvalues.get(countassets).getassetid());                 temp.put(second_column,assetvalues.get(countassets).getassetdescription());                 temp.put(third_column, assetvalues.get(countassets).getinspectorid());                 temp.put(fourth_column,"insert time here");                  list.add(temp);                 countassets++;             }         }         listview lview = (listview) findviewbyid(r.id.listview1);         lview.invalidateviews();         }  public void insertconstant()     {         list.clear();         hashmap temp0 = new hashmap();              temp0.put(first_column, com.example.demoapplication1.constant.first_column);         temp0.put(second_column, com.example.demoapplication1.constant.second_column);         temp0.put(third_column,  com.example.demoapplication1.constant.third_column);         temp0.put(fourth_column,  com.example.demoapplication1.constant.fourth_column);          list.add(temp0);     } 

let me know if require more information

you missed setting adapter on listview :

lview.setadapter(assetadapter); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -