android - how to show inbox messages in list view -


i want show inbox messages in list view. have tried many way's seem there error ..

can tell different approach .

public class inbox extends listactivity  {                   arraylist<string> listitems = new arraylist<string>();         arrayadapter<string> adapter;          protected void oncreate(bundle savedinstancestate)         {                      uri urisms = uri.parse("content://sms/inbox");                cursor c = getcontentresolver().query(urisms, null, null ,null,null);                if(c.movetofirst())                {                              for(int i=0; < c.getcount(); i++)                              {   string body = c.getstring(c.getcolumnindexorthrow("body")).tostring();                                    listitems.add(body);                                  c.movetonext();                              }                              if(listitems.isempty())                                  listitems.add("no messages found !!");                 }                 c.close();                 adapter = new arrayadapter<string>(this,android.r.layout.simple_list_item_1,listitems);                 super.oncreate(savedinstancestate);                 setlistadapter(adapter);          }  } 

why 1 not working . ??

arraylist<string> listitems = new arraylist<string>();     arrayadapter<string> adapter;      protected void oncreate(bundle savedinstancestate)     {                  super.oncreate(savedinstancestate);            uri urisms = uri.parse("content://sms/inbox");            cursor c = getcontentresolver().query(urisms, null, null ,null,null);            if(c.movetofirst())            {                          for(int i=0; < c.getcount(); i++)                          {   string body = c.getstring(c.getcolumnindexorthrow("body")).tostring();                                listitems.add(body);                              c.movetonext();                          }                          if(listitems.isempty())                              listitems.add("no messages found !!");             }             c.close();             adapter = new arrayadapter<string>(this,android.r.layout.simple_list_item_1,listitems);              setlistadapter(adapter);      }  

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -