The MAFCalendarListView shows appointments day by day in a segmented list.
The list includes only days that have appointments, and only the starting times of
the appointments. A segmentation header separates the days. Each appointment appears
as a cell in one of the list view sections. By default, the cell shows description,
location, and starting time. The list view can show appointments of multiple
calendars at the same time. The calendar color code appears at the left side of each
appointment cell:
The following examples use the ListViewActivity Android activity. The content view of this activity is defined in the the_view_embedding_the_list_view.xml layout XML.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent"> <com.sap.maf.uicontrols.calendar.listview.MAFCalendarListView android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>
public void onCreate(...) { super.onCreate(...); // inflate the view that embedded the segmented list view setContentView(R.layout.the_view_embedding_the_list_view); // obtain reference to the list view MAFCalendarListView listView = (MAFCalendarListView) findViewById(R.id.listview); // set the data provider IMAFCalendarDataProvider dataProvider = new MyAppointmentDataProvider(); listView.setDataProvider(dataProvider); // set the time frame to show appointments in. Date start = MAFDateHelper.createDateFromString("01.01.2012 00:00.00"); Date end = MAFDateHelper.createDateFromString("31.12.2012 00:00.00"); listView.setDateRange(start, end); // hook up MAF skinning mechanism, this is a mandatory step MAFSkinManager.getInstance(this); }
You can also set a time/date range to filter the appointments and show only those between the start and end dates.
To be able to skin the UI elements, also hook up the MAF skinning manager.
class ListViewActivity extends Activity implements IMAFCalendarListViewSelectionListener { public void onAppointmentSelected(IMAFAppointment app) { Toast.makeText(this, app.getTitle(), Toast.LENGTH_SHORT).show(); } public void onAppointmentLongPressed(IMAFAppointment app) { Toast.makeText(this, app.getTitle(), Toast.LENGTH_SHORT).show(); } public void onCreate(...) { super.onCreate(...); // inflate the view that embedded the segmented list view setContentView(R.layout.the_view_embedding_the_list_view); // obtain reference to the list view MAFCalendarListView listView = (MAFCalendarListView) findViewById(R.id.listview); // set the data provider // ... // set the time frame to show appointments in. // ... // set action listener listView.setOnSelectionListener(this); } }
For the complete list of public API setter, getter, and modifier methods for the MAFCalendarListView class, see the API reference.