Show TOC

MAFListActivityLocate this document in the navigation structure

MAFListActivity extends the capabilities of the ListActivity native button. MAF adds styling capabilities to the ListActivity UI component.

To create and present a default SAP style instance of MAFListActivity, create an Android activity and inherit its style from MAFListActivity.
public class MyMAFListActivity extends MAFListActivity {

	protected void onCreate(Bundle savedInstanceState) {
		// sample data
		String[] values = new String[] { "Android", "iPhone", "WindowsMobile","Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X","Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux",
"OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2",
"Android", "iPhone", "WindowsMobile" };
		final ArrayList<String> list = new ArrayList<String>();
	    for (int i = 0; i < values.length; ++i) {
	    // set adapter
	    final MAFArrayAdapter<String> adapter = new MAFArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
	    // set a flavor
	    // add action handler
	    getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
	    	public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
	    	  	String item = (String) parent.getItemAtPosition(position);
	    	  	// alert do something with item

	    // reskin UI
	// ...

The MAF skinning engine customizes the list separator color and height of ListActivity. MAFListActivity uses the list view style definition from the default style XML.

This is the XAML content for the default style of the ListView TargetType:
<Style TargetType="ListView" platform="android">
		<Setter Property="Separator" Value="#ffff0000" />
		<!-- separator color -->
		<Setter Property="BorderBrush" Value="2" />
		<!-- separator height -->
You can also inherit the style definition from the standard list view and create a flavored list definition. Here is an example for a red styled list view flavor:
<Style TargetType="ListView" platform="android" BasedOn="DefListView" key=”RedListView”>
		<Setter Property="Separator" Value="#ffff0000" />
		<!-- separator color -->
		<Setter Property="BorderBrush" Value="3" />
		<!-- separator height -->

While the activity is called by the Android system, set the flavor when overwriting the onCreate callback. To achieve this, explicitly call the public void setFlavor(final String flavor) API on the activity.

You can change these properties in the skinning XML:
Separator Separator line color
BorderBrush Separator height