使用一个网路布主的电网布。 你可以利用GridLayout执行点击指挥,并利用一些精炼者的工作,你可以管理周/月的天数。
Edit:
这里是一个粗略的概念,即你可以做些什么,GredView将如何为你工作。
class CalendarView extends LinearLayout {
public CalendarView (Context context) {
super(context);
setOrientation(LinearLayout.VERTICAL);
mHeader = new LinearLayout(context);
mHeader.setOrientation(LinearLayout.HORIZONTAL);
addView(mHeader);
// Add in your days, shouldn t be too bad, they are just text views.
mCalendar = new GridView(context);
mCalendar.setColumns(mHeader.getNumViews()); // You could hard code this.
mCalendar.setAdapterView(new CalendarAdapter());
addView(mCalendar);
}
// ... Other contructors
private class CalendarAdapter extends BaseAdapter {
// Override methods, this should be too bad.
@Override public view getView (int pos, View convert, ViewGroup parent) {
ListView lv = (ListView)convert;
if (convert == null)
lv = new ListView(parent.getContext());
// Here you will need to figure out some way of
// determining the date.
CalendarDate app = (CalendarDate)lv.getTag();
// Determine if this view is already set to the correct date,
// if not rest the list view
app.sort();
lv.setAdapter(new ArrayAdapter(parent.getContext(), R.layout.datelistview, app.getDates());
}
}
public static class CalendarDate {
List<Appointment> mDates = new ArrayList<Appointment>();
public void addAppointment(Appointment app) {
mDate.add(app);
}
// ... and the rest of your methods (getters and state returns)
}
public Appointment implements Compareable<Appointment> {
private Date mDate;
private String mName; // Appointment name
private String mDesc; // Appointment description
@Override public int compareTo(Appointment to) {
return mDate.compareTo(mDate);
}
}
}