MAFListActivity extends the capabilities of the android.app. ListActivity native button. MAF adds styling capabilities to the ListActivity UI component.
public class MyMAFListActivity extends MAFListActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(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) { list.add(values[i]); } // set adapter final MAFArrayAdapter<String> adapter = new MAFArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list); setListAdapter(adapter); // set a flavor setFlavor("RedListView"); // 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 MAFUIFactory.getInstance().reskinUI(this); } // ... }
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.
<Style TargetType="ListView" platform="android"> <Setter Property="Separator" Value="#ffff0000" /> <!-- separator color --> <Setter Property="BorderBrush" Value="2" /> <!-- separator height --> </Style>
<Style TargetType="ListView" platform="android" BasedOn="DefListView" key=”RedListView”> <Setter Property="Separator" Value="#ffff0000" /> <!-- separator color --> <Setter Property="BorderBrush" Value="3" /> <!-- separator height --> </Style>
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.
Separator | Separator line color |
BorderBrush | Separator height |