Posts

Showing posts with the label Counter

Navigation Drawer with counter

Image
In my previous post I described how to create a Navigation Drawer. Some readers asked me how to integrate the menu with a counter, just as it appears in the official documentation . Something like this... I think we can achieve it in many ways. Let's start with row layout. For each row we use a RelativeLayout with a ImageView which is icon, a TextView which is the title and an other TextView which is the counter. Our counter is a simple TextView . We use android:layout_alignParentRight="true" to align it on the right. It is very important this line: android:background="@drawable/rectangle" . We use a rectangular shape with rounded corners to draw the counter's background. Here you can find rectangle.xml: Now we need to adjust our Model and Adapter: public class NsMenuItemModel { public int title; public int iconRes; publ...