android - Inserting items in a list dynamically by class object -
i adding life event event name, start , and time on list view using class object , still not succeeded; have search lot can't find relevant answer. beginner me
public class meetingfragment extends fragment { list<meetings> meetinglist; //here meetings class meetings newmeeting; listview listview; string meetingtag; string[] meetings; arrayadapter<meetings> adapter; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view rootview = inflater.inflate(r.layout.fragment_meeting, container, false); newmeeting = new meetings(); listview = (listview) rootview.findviewbyid(r.id.list_meetings); meetings = new string[] {}; adapter = new arrayadapter<meetings>(getactivity(), r.layout.list_item, r.id.meeting_name); listview.setadapter(adapter); }); //this custom dialog ok.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub string tagmeeting = et.gettext().tostring(); string starttimestr = strttime.gettext().tostring(); string endtimestr = endtime.gettext().tostring(); newmeeting.setmeetingname(tagmeeting); newmeeting.setstarttime(starttimestr); newmeeting.setendtime(endtimestr); //display error on below line meetinglist.add(newmeeting); addmeeting.dismiss(); } });
i not see where/how passing data backs listview
arrayadapter
. when pass data adapter, need reference of it, add new items , call notifydatasetchanged()
on arrayadapter
.