What does “.()” mean in Kotlin?

A function that takes in nothing and returns nothing in Kotlin looks like: var function : () -> Unit The difference is that the function in your code takes in nothing, returns nothing, but is invoked on an object. For example, class Builder (val multiplier: Int) { fun invokeStuff(action: (Builder.() -> Unit)) { this.action() } … Read more

Android – Is Navigation Drawer from right hand side possible?

The NavigationDrawer can be configured to pull out from the left, right or both. The key is the order of appearance of the drawers in the XML declaration, and the layout_gravity attribute. Here is an example: <android.support.v4.widget.DrawerLayout android:id=”@+id/drawer_layout” android:layout_width=”match_parent” android:layout_height=”match_parent” > <FrameLayout android:id=”@+id/content” android:layout_width=”match_parent” android:layout_height=”match_parent” android:baselineAligned=”false” > </FrameLayout> <!– Left drawer –> <ListView android:id=”@+id/left_drawer” android:layout_width=”match_parent” … Read more

How to open Navigation Drawer with no actionbar, open with just a button

It’s giving you a null pointer because you are trying to find the drawer layout in the fragment’s view, when it is actually in the activities view. A quick hack to do what you want is to find the view like: getActivity().findViewById(R.id.drawer_layout) That should work. A better way is to have a method on the … Read more

Set Background Color of Navigation Drawer

In your activity_main.xml include the following <android.support.design.widget.NavigationView android:id=”@+id/navigation_view” android:layout_width=”wrap_content” android:layout_height=”match_parent” android:layout_gravity=”start” app:headerLayout=”@layout/navigation_drawer_header” app:menu=”@menu/menu_drawer” android:background=”@color/color_navigation_list_background” app:itemIconTint=”@color/color_selector_navigation_item” app:itemTextColor=”@color/color_selector_navigation_item”/>

Switch between Fragments with onNavigationItemSelected in new Navigation Drawer Activity template (Android Studio 1.4 onward)

So, based on @L.L.’s answer I was able to solve this problem. First of all, add your FrameLayout to your content_main.xml file: <FrameLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:id=”@+id/content_frame”/> In your MainActivity (or whatever you have named the Activity with the navigation drawer) define a method named displayView public void displayView(int viewId) { Fragment fragment = null; String … 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

Android DrawerLayout – No drawer view found with gravity

From documentation To use a DrawerLayout, position your primary content view as the first child with a width and height of match_parent. Add drawers as child views after the main content view and set the layout_gravity appropriately. Drawers commonly use match_parent for height with a fixed width. <android.support.v4.widget.DrawerLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:id=”@+id/drawer_layout” android:layout_width=”match_parent” android:layout_height=”match_parent” android:fitsSystemWindows=”true”> <LinearLayout … Read more

DrawerLayout’s item click – When is the right time to replace fragment?

Yup, couldn’t agree more, performing a fragment (with view) transaction results in a layout pass which causes janky animations on views being animated, citing DrawerLayout docs: DrawerLayout.DrawerListener can be used to monitor the state and motion of drawer views. Avoid performing expensive operations such as layout during animation as it can cause stuttering; try to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)