Default Navigation Drawer View to ExpandableListView

This is the code for expandable list adapter: public class ExpandListAdapter extends BaseExpandableListAdapter { private Context _context; private List<String> _listDataHeader; // header titles // child data in format of header title, child title private HashMap<String, List<String>> _listDataChild; public ExpandListAdapter(Context context, List<String> listDataHeader, HashMap<String, List<String>> listChildData) { this._context = context; this._listDataHeader = listDataHeader; this._listDataChild = listChildData; … Read more

Change Navigation View Item Color Dynamically Android

use app:itemIconTint in your NavigationView for icons and use app:itemTextColor for textColors Sample : drawable/navigation_text_color : <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <!– This is used when the Navigation Item is checked –> <item android:color=”#009688″ android:state_checked=”true” /> <!– This is the default text color –> <item android:color=”#E91E63″ /> </selector> and layout : <android.support.design.widget.NavigationView . . app:itemTextColor=”@drawable/navigation_text_color”/>

Android – Navigation View item menu background color

You don’t set the drawable for the background of a Navigation View item in your styles.xml file. Open up your XML layout file containing your Navigation View widget, and add the following line to the widget’s attributes: app:itemBackground=”@drawable/activated_background.xml” If you’re having trouble with the “app” pointer, add the following line in as well: xmlns:app=”http://schemas.android.com/apk/res-auto” Note … Read more

Is there a SwiftUI equivalent for viewWillDisappear(_:) or detect when a view is about to be removed?

Here is approach that works for me, it is not pure-SwiftUI but I assume worth posting Usage: SomeView() .onDisappear { print(“x Default disappear”) } .onWillDisappear { // << order does NOT matter print(“>>> going to disappear”) } Code: struct WillDisappearHandler: UIViewControllerRepresentable { func makeCoordinator() -> WillDisappearHandler.Coordinator { Coordinator(onWillDisappear: onWillDisappear) } let onWillDisappear: () -> Void … Read more

How to set custom typeface to items in NavigationView?

just add following class file to your project. import android.graphics.Paint; import android.graphics.Typeface; import android.text.TextPaint; import android.text.style.TypefaceSpan; public class CustomTypefaceSpan extends TypefaceSpan { private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Override public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Override public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } … Read more

How can I change separator color in NavigationView?

just apply following line on style.xml <item name=”android:listDivider”>your_color</item> The below is just information for your knowledge … If you have seen design support library .. they are using following layout for NavigationView seprator.. <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”wrap_content”> <View android:layout_width=”match_parent” android:layout_height=”1dp” android:background=”?android:attr/listDivider”/> </FrameLayout> here, you can see android:background=”?android:attr/listDivider” .. So enjoy … and here is my … Read more

NavigationView menu items with counter on the right

Starting from version 23 of appcompat-v7 NavigationView supports action views, so it is quite easy to implement counter yourself. Create counter layout, i.e. menu_counter.xml: <?xml version=”1.0″ encoding=”utf-8″?> <TextView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”match_parent” android:gravity=”center_vertical” android:textAppearance=”@style/TextAppearance.AppCompat.Body2″ /> Reference it in your drawer menu xml, i.e. menu/drawer.xml: <item … app:actionLayout=”@layout/menu_counter” /> Note that you should use app namespace, don’t … Read more