I Want to add items to NavigationView dynamically. This is possible with the add method of Menu class. I need to add checkbox to all menu items. This is achievable by using actionLayout in XML file with static menu items. For example, see here. But I don't know how to use actionlayout dynamically in this case?
Asked
Active
Viewed 282 times
1 Answers
0
You can add any layout inner NavigationView Tag.enter image description here
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:itemIconTint="@color/green_btn"
app:menu="@menu/nav_menu">
**<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/ck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"></CheckBox>
<TextView
android:layout_toRightOf="@id/ck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="new"
android:textSize="@dimen/maring_padding_20"
android:gravity="center_vertical"
android:layout_gravity="bottom"/>
</RelativeLayout>**
</com.google.android.material.navigation.NavigationView>

veronika
- 1
- 5