android - The application has stopped unexpectedly! Arraylist Hashmaps and TabHost -


i have problem code , don't seem find ! error is...application has stopped unexpectedly! don't have clue what's going on. (i'm devandroid begginer) first tab works ok, when switch second 1 arraylist hashmap, crashes.

here bonuriactivity code:

public class bonuriactivity extends listactivity {  public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.tab_bonuri);      final string url="http://xxxzzz/throwdata.php?p=bonuri";      listview lv = (listview) findviewbyid(android.r.id.list);     simpleadapter adapter = new simpleadapter(bonuriactivity.this,             getbonuri(url), r.layout.list_bon,              new string[] {"produs", "cantitate", "um", "idvinzare"},             new int[] { r.id.produs, r.id.cantitate, r.id.um, r.id.idvinzare });     lv.setadapter(adapter); }  private arraylist<hashmap<string,string>> getbonuri(string key_121) {         inputstream = null;        string result = "";           hashmap<string,string> entitieshashmap = new hashmap<string, string>();        arraylist<hashmap<string, string>> returnstring = new arraylist<hashmap<string,string>>();          //http post         try{                 httpclient httpclient = new defaulthttpclient();                 httppost httppost = new httppost(key_121);                 httpresponse response = httpclient.execute(httppost);                 httpentity entity = response.getentity();                 = entity.getcontent();          }catch(exception e){                 log.e("log_tag", "error in http connection "+e.tostring());         }          //convert response string         try{                 bufferedreader reader = new bufferedreader(new inputstreamreader(is,"iso-8859-1"),8);                 stringbuilder sb = new stringbuilder();                 string line = null;                 while ((line = reader.readline()) != null) {                         sb.append(line + "\n");                 }                 is.close();                 result=sb.tostring();         }catch(exception e){                 log.e("log_tag", "error converting result "+e.tostring());         }         //parse json data         try{                 jsonarray jarray = new jsonarray(result);                 for(int i=0;i<jarray.length();i++){                         jsonobject json_data = jarray.getjsonobject(i);                                             //get output screen                         entitieshashmap.put("produs", json_data.getstring("produs"));                         entitieshashmap.put("cantitate", json_data.getstring("cantitate"));                         entitieshashmap.put("um", json_data.getstring("um"));                         entitieshashmap.put("idvinzare", json_data.getstring("idvinzare"));                         returnstring.add(entitieshashmap);                 }         }catch(jsonexception e){                 log.e("log_tag", "error parsing data "+e.tostring());         }          return returnstring;      }       } 

and here tabbonuri.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/tab2layout">  <listview android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent"> </listview>  </linearlayout> 

and list_bon.xml

<?xml version="1.0" encoding="utf-8"?> <linearview xmlns:android="http://schemas.android.com/apk/res/android"> <textview android:id="@+id/um" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dp" android:text="um" android:textsize="16sp" > </textview>  <textview android:id="@+id/cantitate" android:layout_width="wrap_content" android:layout_height="21px" android:padding="10dp" android:text="cantitate" android:textsize="16sp" > </textview> <textview android:id="@+id/produs" android:layout_width="121px" android:layout_height="22px" android:padding="10dp" android:text="produs" android:textsize="16sp" > </textview> <textview android:id="@+id/idvinzare" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="invisible" android:text="textview" /> </linearview> 

i gradly thank time spent helping me. please comment if see why program crashing, cause i'm stressed out ('ve been on 2 days, it's frustrating).

apparently have no idea can find logcat...

if develop eclipse, take here: http://developer.android.com/guide/developing/debug-tasks.html error message find there need you. copy&paste question.

if want learn how debug, here small how it: http://www.droidnova.com/debugging-in-android-using-eclipse,541.html

update

ok screenshot logcat isn't best way provide error shows blundell suggested: fetch internet in ui thread. read this: http://developer.android.com/guide/practices/design/responsiveness.html , fetching of internet stuff should done that: http://developer.android.com/reference/android/os/asynctask.html


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -