java - 2-line list view not appearing -


i'm trying create 2-line list view in activity i've come across 1 error don't know how fix. how can achieve appcompat way? want achieve in screenshot attached. error on line 52.

public class wclineactivity extends actionbaractivity {      private class sample {         private charsequence title;         private charsequence summary;         private class<? extends activity> activityclass;          public sample(int titleresid, int summaryresid, class<? extends activity> activityclass) {             this.activityclass = activityclass;             this.title = getresources().getstring(titleresid);             this.summary = getresources().getstring(summaryresid);          }          @override         public string tostring() { return title.tostring(); }         public string getsummary(){ return summary.tostring(); }     }      private static sample[] msamples;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_wc_line);          // instantiate list of samples.         msamples = new sample[]{                 new sample(r.string.bank, r.string.zone_1, mainactivity.class),                 new sample(r.string.waterloo, r.string.zone_1, mainactivity.class)         };          setlistadapter(new myadapter(this, msamples));     }      static class myadapter extends baseadapter {          static class viewholder {             textview title;             textview summary;         }          layoutinflater inflater;         sample[] msamples;          public myadapter(context contexts, sample[] samples) {             this.msamples = samples;             inflater = layoutinflater.from(contexts);          }          @override         public int getcount() {             return msamples.length;         }          @override         public object getitem(int position) {             return msamples[position];         }          @override         public long getitemid(int position) {             return 0;         }          @override         public view getview(int position, view convertview, viewgroup parent) {             viewholder viewholder;             if (convertview == null) {                 convertview = inflater.inflate(r.layout.list_item_dualline, null);                 viewholder = new viewholder();                  viewholder.title = (textview) convertview.findviewbyid(r.id.list_item_title);                 viewholder.summary = (textview) convertview.findviewbyid(r.id.list_item_subtitle);                 convertview.settag(viewholder);             } else {                 viewholder = (viewholder) convertview.gettag();             }             viewholder.title.settext(msamples[position].title);             viewholder.summary.settext(msamples[position].getsummary());             return convertview;         }     } } 

phone

error

enter image description here

i tried code

    protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_wc_line);     listview listview = (listview) findviewbyid(r.id.listview);     // instantiate list of samples.     msamples = new sample[]{             new sample(r.string.bank, r.string.zone_1, mainactivity.class),             new sample(r.string.waterloo, r.string.zone_1, mainactivity.class)     };      listview.setadapter(new myadapter(this, msamples));     } 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -