hier ist eine Beispielanwendung, die es macht:
PrashamTrivedi/DrawerLayoutTest
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.drawer_group_item,parent,false);
}
((TextView) convertView).setText(groupItem.get(groupPosition));
convertView.setTag(groupItem.get(groupPosition));
return convertView;
}
@Override
public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent)
{
tempChild = (ArrayList<String>) children.get(groupPosition);
TextView text = null;
if (convertView == null)
{
LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.drawer_submenu_item,parent,false);
}
text = (TextView) convertView;
text.setText(tempChild.get(childPosition));
convertView.setTag(tempChild.get(childPosition));
return convertView;
}
Und Sie haben die neuen XML-Dateien im Layout-Ordner erstellen (Hinweis: zwei, eine für die Gruppenansicht und andere für das Untermenü)
Nach all Ihrer Seite Navigation muss wie folgt aussehen:
EDIT: Simple Navigational Drawer Layout in Android
Es hat eine ExpandableListView ist, können Sie Kind hinzufügen nur Eltern 5. – Milan
@Milanix Eigentlich muss ich hinzufügen, Kinder Eltern 5 & Elternteil 7, ist das nicht möglich? –
Also, was ist das Problem? Verwenden Sie ExpirableListView wie zuvor erwähnt. – Milan