im having a problem with this code:
public void calendarview()
{
lv = (ListView) findViewById(R.id.calendarlist);
SharedPreferences pref = getApplicationContext().getSharedPreferences(
"animobile", MODE_PRIVATE);
int size = pref.getInt("clength", 0);
String cdate[] = new String[size];
String cevent[] = new String[size];
for(int i=0;i<size;i++){
cdate[i] = pref.getString("cdate" + i, null);
cevent[i] = pref.getString("cdate" + i, null);
}
Log.w("athan","kalendaryo"+size);
ArrayAdapter<String> arrayAdapter =
new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, cdate);
lv.setAdapter(arrayAdapter);
}
with lv as listview like this:
private ListView lv;
now the problem is, i have this array cdate
and cevent
and i want them to be listed on an arrayadapter, but arrayadapter accepts only one arraylist.
i have also read lots of other related questions, but i only end up with same answer, "you have to make a custom adapter". but with this code, is it possible with custom adapter? the code is inside the:
public class calendarview extends Activity {
EDIT: im still stuck, i created a class just like trevor-e said, this is the code:
class Event {
private String cdate;
private String cevent;
public Event(String date, String event) {
this.cdate = date; this.cevent = event;
}
public void setcdate(String cdate) {
this.cdate = cdate;
}
public void setcevent(String cevent) {
this.cevent = cevent;
}
public String cevent() {
return cevent;
}
public String cdate() {
return cdate;
}
//getters and setters
}
and the ArrayAdapter is changed to:
ArrayAdapter<Event> arrayAdapter =
new ArrayAdapter<Event>(this,android.R.layout.simple_list_item_1);
now the code does not give any values. im a missing something? it feels like i have to set the array into this class but i dont know how.