java - ListView based on own class -


im new in android developing, have problem dynamic list.

i have habit class , habitmemorydao class , want make listview in main class habits. can wrote main class listview show habits. thanks

public class habit {      private string name;     private date startdate;     private int duration;     private int frequencyinweek; // 1 7     private string awardtext;       public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     }      public date getstartdate() {         return startdate;     }      public void setstartdate(date startdate) {         this.startdate = startdate;     }      public int getduration() {         return duration;     }      public void setduration(int duration) {         this.duration = duration;     }      public int getfrequencyinweek() {         return frequencyinweek;     }      public void setfrequencyinweek(int frequency) {         this.frequencyinweek = frequency;     }      public string getaward() {         return awardtext;     }      public void setaward(string award) {         this.awardtext = award;     } }  public class habitmemorydao {      private list<habit> habitlist = new linkedlist<habit>();      public habitmemorydao() {         habit habit1 = new habit();         habit1.setname("running");         habit1.setduration(30);         habit1.setfrequencyinweek(2);         habit1.setstartdate(new date());         habitlist.add(habit1);          habit habit2 = new habit();         habit2.setname("swimming");         habit2.setduration(15);         habit2.setfrequencyinweek(7);         habit2.setstartdate(new date());         habitlist.add(habit2);     }       public list<habit> gethabitlist() {         return habitlist;     } 

what need understand how listview , adapters work each other:

so there 2 ways start: can use arrayadapter, uses tostring() method of habit class show list of habits in listview or use more powerful class baseadapter. suggest learn how baseadapter works, since array adapter subclass of baseadapter. simple tutorial baseadapters

btw: it's not idea ask people writes concrete code. welcome ask questions concrete problems , people answer (most of times code snippets).


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -