android - How can I connect ListView to CustomListView -


firstly made listview want make listview icons. for;(this custom adapter , of course have xml it. listeozellikleri.xml)

public class listeozellikleri extends arrayadapter<string> {     private final context context;     private final string[] values;      public listeozellikleri(context context, string[] values) {         super(context, r.layout.liste_ozellikleri, values);         this.context = context;         this.values = values;     }      @override     public view getview(int position, view convertview, viewgroup parent) {         layoutinflater inflater = (layoutinflater) context             .getsystemservice(context.layout_inflater_service);          view rowview = inflater.inflate(r.layout.liste_ozellikleri, parent, false);         textview textview = (textview) rowview.findviewbyid(r.id.logoisim);         imageview imageview = (imageview) rowview.findviewbyid(r.id.logosimge);         textview.settext(values[position]);          // change icon based on name         string s = values[position];          system.out.println(s);          if (s.equals("photo1")) {             imageview.setimageresource(r.drawable.image1);         } else if (s.equals("photo2")) {             imageview.setimageresource(r.drawable.image2);         } else if (s.equals("photo3")) {             imageview.setimageresource(r.drawable.image3);         } else if (s.equals("photo4")) {             imageview.setimageresource(r.drawable.image4);         }          return rowview;     } } 

and main listview;

    textview dogrusonuc;     textview bossonuc;     listview sonuclistesi;     context context;     //logo verileri icin adaptor acma baslangic     arraylist<string> veriler; {     veriler = new arraylist<string>();     }     //logo verileri icin adaptor acma bitis      @override     protected void oncreate(bundle savedinstancestate) {          //tam ekran kodu baslangic         requestwindowfeature(window.feature_no_title);         getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,                 windowmanager.layoutparams.flag_fullscreen);         //tam ekran kodu bitis           super.oncreate(savedinstancestate);         setcontentview(r.layout.sonuclar);                 //logo verileri cekme baslangic         intent veri = getintent();           veriler = veri.getstringarraylistextra("logoveri");         //logo verileri cekme bitis          //liste olusturma baslangic         listview sonuclistesi=(listview) findviewbyid(r.id.sonuclistesi);         arrayadapter<string> veriadaptoru=new arrayadapter<string>(this, android.r.layout.simple_list_item_1, veriler);         sonuclistesi.setadapter(veriadaptoru);         //liste olusturma bitis                  //sonuclari yazdirma baslangic         dogrusonuc = (textview)findviewbyid(r.id.dogrusonuc);         dogrusonuc.settext("doğru sayınız: " + getintent().getextras().getstring("dogruveri"));          bossonuc = (textview)findviewbyid(r.id.bossonuc);         bossonuc.settext("boş sayınız: " + getintent().getextras().getstring("bosveri"));         //sonuclari yazdirma bitis      }     private abslistview sonuclistesi() {         // todo auto-generated method stub         return null;     } } 

how can connect custom adapter main listview? because need show datas icons... *when intent add photo1 listview image1 item's icon...

instead of -
arrayadapter veriadaptoru=new arrayadapter(this, android.r.layout.simple_list_item_1, veriler); sonuclistesi.setadapter(veriadaptoru);

use below.

    listeozellikleri madapter = new listeozellikleri(this,veriler);     sonuclistesi.setadapter(veriadaptoru); 

and practice have class names starting in caps. listeozellikleri should listeozellikleri.

also if veriler arraylist, should change string[] values in adapter arraylist values.

change adapter below

     public class listeozellikleri extends arrayadapter<string> { private final context context; private final arraylist<string> values;  public listeozellikleri(context context, arraylist<string> values) {     super(context, r.layout.liste_ozellikleri, values);     this.context = context;     this.values = values; }  @override public view getview(int position, view convertview, viewgroup parent) {     layoutinflater inflater = (layoutinflater) context         .getsystemservice(context.layout_inflater_service);      view rowview = inflater.inflate(r.layout.liste_ozellikleri, parent, false);     textview textview = (textview) rowview.findviewbyid(r.id.logoisim);     imageview imageview = (imageview) rowview.findviewbyid(r.id.logosimge);     textview.settext(values.get(position));      // change icon based on name     string s = values.get(position);      system.out.println(s);      if (s.equals("photo1")) {         imageview.setimageresource(r.drawable.image1);     } else if (s.equals("photo2")) {         imageview.setimageresource(r.drawable.image2);     } else if (s.equals("photo3")) {         imageview.setimageresource(r.drawable.image3);     } else if (s.equals("photo4")) {         imageview.setimageresource(r.drawable.image4);     }      return rowview; } 

}


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -