Developer

List View

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:

List View

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.

Creating the Control

To embed a MAFCalendarListView in the ListViewActivity’s custom content view, place the com.sap.maf.uicontrols.calendar.MAFCalendarListView control tag into the the_view_embedding_the_list_view.xml file, similar to adding a subview to a custom content view:
<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>

Initializing the Control

After obtaining reference to the list view instance, set the appointment data provider in the code in the onCreate(…) method of the ListViewActivity. Set, for example, the MyAppointmentDataProvider object, which was defined in the first code example of this topic, for the list view instance:
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.

Interacting with the MAFCalendarListView Instance

To get notifications about user selections (by short or long tap) on the control, set a listener object for the list view by implementing the IMAFCalendarListViewSelectionListener interface. This interface is defined for the calendar list view control. Choose the activity that controls the list view to be the listener object. In this example, the ListActivityView is the activity holding and controlling the calendar list view. To create the interface implementer object, use:
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.