Tôi đang cố gắng thêm các mục menu mới vào menu phụ trong bảng ngăn kéo Material Design mới.Cách lập trình thêm mục menu phụ vào thư viện hỗ trợ android design material mới
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
...
<android.support.design.widget.NavigationView
android:id="@+id/main_navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/channel_list_header"
app:menu="@menu/menu_nav" />
</android.support.v4.widget.DrawerLayout>
tôi làm có @ menu/cài đặt menu_nav nhưng bây giờ muốn để thêm các mục trình đơn mới:
NavigationView mDrawerList = (NavigationView) findViewById(R.id.main_navigation);
Menu menu = mDrawerList.getMenu();
Menu topChannelMenu = menu.addSubMenu("Top Channels");
topChannelMenu.add("Foo");
topChannelMenu.add("Bar");
topChannelMenu.add("Baz");
mDrawerList.invalidate(); // Trying to force a redraw, doesn't help.
Các mục trình đơn từ file @ menu/menu_nav được hiển thị, nhưng những người mới được bổ sung không phải. Bất kỳ ý tưởng nào về cách thực hiện điều đó?
Ông có thể liên kết các báo cáo lỗi xin vui lòng? – Moritur
đây là liên kết: https://code.google.com/p/android/issues/detail?id=176300 – Moinkhan