android - Not able to building Custom List View with multiple string arrays -


i trying make activity this

enter image description here

so started creating custom listview have static values of text displayed. created 2 xml files i.e 1 edittext, button , listview , other 1 describing row of listview.

my java code follow

    package com.ved_copy.copy;      import android.app.activity;     import android.os.bundle;     import android.view.view;     import android.widget.adapterview;     import android.widget.listview;     import android.widget.toast;      public class mainactivity extends activity {   listview list;   string[] name = { "shailene woodley", "susan coffey", "jennifer lawrence",         "emma watson", "emma stone" };  string[] question = { "is vishesh single?", "net scap navigator",         "who primeminister of japan", "popullation growth rate",         "will uganda super power" };  string[] solution = { "solution:12", "solution:6", "solution:11",         "solution:2", "solution:23" };  string[] date = { "24/6/14", "22/6/14", "22/6/14", "10/6/14", "27/5/14" };  integer[] imageid = { r.drawable.woodley, r.drawable.susan,         r.drawable.jennifer, r.drawable.emma, r.drawable.stone };  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      customlist adapter = new customlist(mainactivity.this, name, question,             solution, date, imageid);     list = (listview) findviewbyid(r.id.list);     list.setadapter(adapter);     list.setonitemclicklistener(new adapterview.onitemclicklistener() {         @override         public void onitemclick(adapterview<?> parent, view view,                 int position, long id) {             toast.maketext(mainactivity.this,                     "you clicked @ " + name[+position], toast.length_short)                     .show();         }     });  }     } 

and 1 extends arrayadapter follows

    package com.ved_copy.copy;      import android.app.activity;     import android.view.layoutinflater;     import android.view.view;     import android.view.viewgroup;     import android.widget.arrayadapter;     import android.widget.imageview;     import android.widget.textview;      public class customlist extends arrayadapter<string> {  private final activity context; private final string[] name; private final string[] question; private final string[] solution; private final string[] date; private final integer[] imageid;  public customlist(activity context, string[] name, string[] question,         string[] solution, string[] date, integer[] imageid) {     super(context, r.layout.list_row, name);     this.context = context;     this.name = name;     this.imageid = imageid; }   @override public view getview(int position, view convertview, viewgroup parent) {     layoutinflater inflater = context.getlayoutinflater();     view row = inflater.inflate(r.layout.list_row, null, true);      textview txtquestion = (textview) row.findviewbyid(r.id.tv_question);     textview txtsolution = (textview) row.findviewbyid(r.id.tv_solution);     textview txtname = (textview) row.findviewbyid(r.id.tv_name);     textview txtdate = (textview) row.findviewbyid(r.id.tv_date);     imageview imageview = (imageview) row.findviewbyid(r.id.iv_image);     txtquestion.settext(question[position]);     txtsolution.settext(solution[position]);     txtname.settext(name[position]);     txtdate.settext(date[position]);     imageview.setimageresource(imageid[position]);     return row; }      } 

but there problem constructor me fix thanks.

maybe can use baseadapter example

public class mynewsarrayadapter extends baseadapter { activity context; string title[]; string description[]; int att[]; int ph[];  public mynewsarrayadapter(activity context, string[] title,         string[] description, int[] att, int[] ph) {     super();     this.context = context;     this.title = title;     this.description = description;     this.att = att;     this.ph = ph; } ... 

it's me, when used 3 textview , 2 imageview.
, sorry english..


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -