android - Adapter Not Showing Anything -


i want make view bellow :

enter image description here

for control it, made json in class variabel, activity :

    public class kategorinomorpolis extends listactivity{      listview lv_epolicy;     arrayadapter<string> adapter;      list<string> list = new arraylist<string>();     string[][] c = new string[10][10];      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.epolicy_list_polis);          adapter=new arrayadapter<string>(this,r.layout.list_item);         kategori_epolicy();     }      private void kategori_epolicy(){         string result=listpolis.json_kategori;         jsonarray array=null;         try{             array= new jsonarray(result);             (int i=0;i<array.length();i++){                 jsonobject object = array.getjsonobject(i);                 c[i][0] = object.getstring("id_kategori");                 c[i][1] = object.getstring("kategori"); //              adapter.insert(object.getstring("kategori"), i);                 system.out.println("yuhuuu");             }             lv_epolicy=(listview)findviewbyid(android.r.id.list);             kategoriepolicyadapter adapter = new kategoriepolicyadapter(kategorinomorpolis.this, array);             lv_epolicy.setadapter(adapter);             lv_epolicy.setcachecolorhint(color.transparent);          }catch (exception e) {          toast.maketext(getbasecontext(), e.getmessage(), toast.length_short).show();         } 

i have no idea why adapter not showing anything,i have declare listview lv_epolicy=(listview)findviewbyid(android.r.id.list); , nothing happen , kategoriepolicyadapter :

public class kategoriepolicyadapter extends baseadapter{ context context; jsonarray array; int count; public kategoriepolicyadapter(context context, jsonarray array){     this.context = context;     this.array = array;     this.count = array.length(); }  public int getcount() {     // todo auto-generated method stub     return count; }  public object getitem(int arg0) {     // todo auto-generated method stub     return null; }  public long getitemid(int arg0) {     // todo auto-generated method stub     return 0; }  public view getview(int position, view contentview, viewgroup arg2) {     // todo auto-generated method stub      layoutinflater inflater = (layoutinflater)context.getsystemservice(context.layout_inflater_service);     contentview = inflater.inflate(r.layout.epolicy_kategori, null);      imageview img_epolicy = (imageview)contentview.findviewbyid(r.id.img_epolicy);     textview text_kategori  = (textview)contentview.findviewbyid(r.id.text_kategori);     string result=listpolis.json_kategori;     try {         jsonobject object = array.getjsonobject(position);         text_kategori.settext(object.getstring("kategori"));         system.out.println("bisa ga ya? ");          switch(position){         case 0:                 img_epolicy.setimageresource(r.drawable.pp_icon);             break;         case 1:                 img_epolicy.setimageresource(r.drawable.tertanggung_icon);             break;         case 2:             img_epolicy.setimageresource(r.drawable.dataasuransi_icon);             break;         case 3:             img_epolicy.setimageresource(r.drawable.manfaat_icon);             break;         case 4:             img_epolicy.setimageresource(r.drawable.inventaris_icon);             break;         case 5:             img_epolicy.setimageresource(r.drawable.status_icon);             break;         case 6:             img_epolicy.setimageresource(r.drawable.rekening_icon);             break;          }     } catch (exception e) {         // todo: handle exception     }      return contentview; } 

i hope can tell me fault....

you adding array json array. not add json array, add things in list , add list in place of array.

kategoriepolicyadapter adapter = new kategoriepolicyadapter(kategorinomorpolis.this, array); 

it should that:

kategoriepolicyadapter adapter = new kategoriepolicyadapter(kategorinomorpolis.this, list); 

better see adapter

public class testlistadapter extends arrayadapter {

private layoutinflater minflater=null; private httpimagemanager mhttpimagemanager=null;     private arraylist<seedobject> listdata=null;   public testlistadapter(activity context,arraylist<seedobject> list, list<uri> uris) {     super(context, 0, uris);      minflater = context.getlayoutinflater();     this.listdata=list;      mhttpimagemanager = ((testapplication) context.getapplication()).gethttpimagemanager(); }   public view getview(int position, view convertview, viewgroup parent) {      final viewholder holder;      if (convertview == null || convertview.gettag() == null) {         holder = new viewholder();         convertview = minflater.inflate(r.layout.custom_row, null);          holder.url = (textview) convertview.findviewbyid(r.id.text_list);         holder.city = (textview) convertview.findviewbyid(r.id.text_city);         holder.image = (imageview) convertview.findviewbyid(r.id.image_list);         convertview.settag(holder);     }     else {         holder = (viewholder) convertview.gettag();     }      final uri uri = getitem(position);               imageview imageview = holder.image;          if(uri != null){         bitmap bitmap = mhttpimagemanager.loadimage(new httpimagemanager.loadrequest(uri, imageview));                   if (bitmap != null) {                            // image download compress , set on image view             bitmap = bitmap.createscaledbitmap(bitmap, 60, 60, true);             imageview.setimagebitmap(bitmap);         }                    else if(position %2== 0){             imageview.setimageresource(r.drawable.greenseed_new);         }         else{             imageview.setimageresource(r.drawable.grayseed_new);         }      }      //set seed name     holder.url.settext(listdata.get(position).gettitle());     string distance =listdata.get(position).getdistance();       return convertview; }  private static class viewholder {     imageview image;     textview city;     textview url; } 

}


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -