The MAF Tree View component provides a UI representation of a hierarchical list. It can show list items, which can in turn contain child-node list items. MAF Tree View has two modes: a browsing mode, and an editing mode. MAF Tree View supports skinnability via the MAF skinning engine.
The MAF Tree View control is a complex reusable control, which means that it is built on top of simple controls, such as MAFActionBar and MAFListView. The Tree Viewer control depends on the MAFUIControls library and the MAFLogger.
MAFTreeView tView = new MAFTreeView(this, root, inEditMode); aLayout.addView(tView);
<com.sap.maf.uicontrols.view.MAFTreeView xmlns:x="http://schemas.sap.com/maf/2011/ux" android:id="@+id/treeview" android:layout_width="match_parent" android:layout_height="match_parent" >
MAF Tree View nodes are represented with the MAFTreeNode interface, which is located in the com.sap.maf.uicontrols.data package. MAF provides a default implementation for the MAFTreeNode in the MAFTreeNodeImpl class in the same package. Use the default implementation both for node elements containing child elements, and for leaf elements that have no child elements.
public MAFTreeView(Context context, MAFTreeNode root) public MAFTreeView(Context context, MAFTreeNode root, boolean inEditMode) public MAFTreeView(Context context, MAFTreeNode root, String flavor, boolean inEditMode)
To remove an element from the Tree View, use the public void removeItem(MAFTreeNode node) API.
In editing mode, you can select leaf items and perform different actions on the selected items. To switch to editing mode, tap the Edit button on the UI. To set the default to editing mode, set it in the proper constructor. To check whether the Tree View is in editing mode, call the public boolean inEditMode() API, which returns the state of the Tree View.
To perform actions on the selected items, use the public void addTreeViewActionItem(MAFActionBarItem action) API. Because the footer is an extension of MAFActionBar, the API waits for MAFActionBarItem instances, where you can implement the logic in the public void performAction function.
MAFActionBarItem hello_action = new MAFActionBarItem(1, R.drawable.hello, R.string.Hello_Action) { @Override public void performAction() { List<MAFTreeNode> sel_nodes = tView.getSelectedNodes(); … } }; tView.addTreeViewActionItem(hello_action);