android - Adapter not working with listview -


i want display icons in listview. here adapter

public class iconadapter extends baseadapter {     private int[] iconlist;     private context context;     public iconadapter(int[] iconlist, context contex) {         this.iconlist = iconlist;         this.context = context;     }      @override     public int getcount() {         return 0;     }      @override     public object getitem(int position) {         return null;     }      @override     public long getitemid(int position) {         return 0;     }      @override     public view getview(int position, view convertview, viewgroup parent) {          imageview mimageview = new imageview(context);         mimageview.setbackgroundresource(iconlist[position]);         return mimageview;     } } 

this how set adapter

int[] iconlist = new int[]{r.drawable.ic_action_content_new, r.drawable.ic_color_lens_black_48dp}; holder.mlistview.setadapter(new iconadapter(iconlist, context)); 

the problem listview doesn't display anything

your getcount() method returns 0...

change to:

    @override     public int getcount() {         return iconlist.length;     }      @override     public object getitem(int position) {         return iconlist[position];     }      @override     public long getitemid(int position) {         return position;     }    

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -