java - What to do to prevent SimpleAdapter from crashing? -


i'm trying populate listview... in main.java have this:

...     listviewmain=(listview)findviewbyid(r.id.lv1);      popvidlist pvl = new popvidlist();     pvl.populatevideolist(listviewmain); ... 

and in popvidlist.java this:

package rob.youtube.com;  import java.util.arraylist; import java.util.hashmap;  import android.app.activity; import android.widget.listview; import android.widget.simpleadapter;  public class popvidlist extends activity {      private arraylist <hashmap<string, object>> vidarray;     private static final string listvidtext1 = "mythbusters";     private static final string listvidtext2 = "by jamie";     private static final string listvidtext3 = "3 month ago";     private static final string imgkey = "iconfromraw";   public void populatevideolist( listview listviewmain ) {      vidarray = new arraylist<hashmap<string,object>>();     hashmap<string, object> hm;      hm = new hashmap<string, object>();     hm.put(listvidtext1, "mythbusters");     hm.put(listvidtext2, "by jamie | 132.123 views");     hm.put(listvidtext3, "3 month ago | +328 / - 14");     hm.put(imgkey, r.drawable.vid_mb);      vidarray.add(hm);      simpleadapter adapter = new simpleadapter(this, vidarray, r.layout.listview_video, new string[]{listvidtext1,listvidtext2,listvidtext3,imgkey}, new int[]{r.id.listvid_text1, r.id.listvid_text2, r.id.listvid_text3, r.id.listvid_img});        /// crashes here. maybe 'this' should replaced something?      listviewmain.setadapter(adapter);     listviewmain.setchoicemode(listview.choice_mode_single);   }  } 

yet upon launch crashes. method worked fine within main.java, before moved out separate file. guess have line:

simpleadapter adapter = new simpleadapter(this, vidarray, r.layout.listview_video, new string[]{listvidtext1,listvidtext2,listvidtext3,imgkey}, new int[]{r.id.listvid_text1, r.id.listvid_text2, r.id.listvid_text3, r.id.listvid_img}); 

maybe should replace "this" something?...


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -