0

I am new to android. I am trying to make a navigation drawer with the help this URL.

Everything works perfectly except one thing.

In my activity_home layout, when I try to add a menu(named drawer_view), in design view of this layout, it is displaying a rendering problem.

enter image description here

Its been about a day that I tried on google for the solution but nothing works.

Please help me out for the same.

Here is the activity_home.xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!-- The main content view -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

    <!-- The ActionBar displayed at the top -->
    <include
        layout="@layout/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />
    </LinearLayout>
    <android.support.design.widget.NavigationView
        android:id="@+id/nvView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@android:color/white"
        app:menu="@menu/drawer_view"
        app:headerLayout="@layout/nav_header"
        />

</android.support.v4.widget.DrawerLayout>

Here is the drawer_view.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <group android:id="@+id/group_feature"
        android:checkableBehavior="single"

        >
        <item android:id="@+id/first_item"
            android:checked="true"
            android:icon="@drawable/coc"
            android:title="@string/first_name"/>
        <item android:id="@+id/second_item"
            android:checked="true"
            android:icon="@drawable/cricinfo"
            android:title="@string/second_name"/>

        <item android:id="@+id/third_item"
            android:checked="true"
            android:icon="@drawable/flipkart"
            android:title="@string/third_name"/>

    </group>
    <group android:id="@+id/group_settings"
        android:checkableBehavior="single">
        <item android:id="@+id/navdrawer_item_settings"
            android:icon="@drawable/setting"
            android:title="@string/action_settings"/>

    </group>
</menu>

Here is my style.xml file

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#673AB7</item>
        <item name="colorPrimaryDark">#512DA8</item>
        <item name="colorAccent">#FF4081</item>

    </style>

Here is the nav_header.xml code

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="192dp"
    android:background="?attr/colorPrimaryDark"
    android:padding="16dp"
    android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
    android:orientation="vertical"
    android:gravity="bottom">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Header"
        android:textColor="@android:color/white"
        android:textAppearance="@style/Base.TextAppearance.AppCompat.Body1"/>

</LinearLayout>

Thanks

deepak.mr888
  • 349
  • 2
  • 11
  • 26
  • can you please post a code of your .xml – Kishan Soni Dec 01 '15 at 05:55
  • First See your question, You post about `android.widget.TextView.setTextColor` then where is your `TextView` and where is your code for `setTextColor` ??? – Chirag Savsani Dec 01 '15 at 06:04
  • The stacktrace indicates that the exception is raised from the `getView()` method of your ListAdapter. Please paste the source code for that method – W.K.S Dec 01 '15 at 06:06
  • Yeah thats what freaking me out, There is no such TextView in my whole code, still it is displaying this error. When I remove the menu items in drawer_view.xml, this rendering problem will get remove. – deepak.mr888 Dec 01 '15 at 06:07
  • this question is About rendering or Textview ?,if it is about rendering Change Your Android Version in the layout Preview. – Ramesh Bhupathi Dec 01 '15 at 06:10
  • Ya sometime this happens in xml view but when you run your code may be problem can solve. Did you run your code? First clean project and run your code. – Chirag Savsani Dec 01 '15 at 06:15
  • I did change the Android Version in layout Preview and also clean and build my project, still getting the same rendering error :( – deepak.mr888 Dec 01 '15 at 06:17
  • Are you populating Listview inside your Framelayout using any fragment? – PunitD Dec 01 '15 at 06:24
  • 1
    @deepak.mr888 The rendering tool isn't perfect. Try running it on an actual device, it probably works fine. To answer the question of where this mysterious TextView is coming from: NavigationView internally uses a ListView and populates it with a row for each menu item, and that row contains a TextView (surprise). – Karakuri Dec 01 '15 at 06:26
  • @Karakuri thats really surprised me. I think thats what creating the issue. But when I try to install the app in my device, it is not allowing it to do the same because of that problem. – deepak.mr888 Dec 01 '15 at 06:42
  • @droidwala, no I am not population any listview inside my framelayout – deepak.mr888 Dec 01 '15 at 06:42
  • please post your nav_header.xml code over here... – PunitD Dec 01 '15 at 06:44
  • i did edit my ques and post my nav_header.xml code – deepak.mr888 Dec 01 '15 at 06:49
  • @karakuri, Thanks for your comment, I got the solution. Just added : app:itemTextColor in my navigationview and it works. :) – deepak.mr888 Dec 01 '15 at 06:52

0 Answers0