lewisjdeane / L-Navigation-Drawer

Library allowing you to easily replicate the new style of navigation drawer from Android L.
105 stars 20 forks source link

layout inflator error #2

Open Mansourali opened 10 years ago

Mansourali commented 10 years ago

Hello and thanks fro this great work Lewis I have an issue regarding include the library tag into xml file ? when the app is start to running and try to set the content view it's crash with a message says that inflation exception: binary xml file line ...... error inflating class uk.me.lewisdeane.lnavigationdrawer.NavigationListView what I made wrong here ? thanks

lewisjdeane commented 10 years ago

I don't know, I'd have to see your code.

locomain commented 10 years ago

same here!

09-30 19:46:52.441: E/AndroidRuntime(11420): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locomain.nexplay/com.locomain.nexplay.ui.activities.HomeActivity}: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2317) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.app.ActivityThread.access$800(ActivityThread.java:143) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.os.Handler.dispatchMessage(Handler.java:102) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.os.Looper.loop(Looper.java:135) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.app.ActivityThread.main(ActivityThread.java:5070) 09-30 19:46:52.441: E/AndroidRuntime(11420): at java.lang.reflect.Method.invoke(Native Method) 09-30 19:46:52.441: E/AndroidRuntime(11420): at java.lang.reflect.Method.invoke(Method.java:372) 09-30 19:46:52.441: E/AndroidRuntime(11420): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:836) 09-30 19:46:52.441: E/AndroidRuntime(11420): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:631) 09-30 19:46:52.441: E/AndroidRuntime(11420): Caused by: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.widget.AdapterView.addView(AdapterView.java:482) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.view.LayoutInflater.rInflate(LayoutInflater.java:805) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.view.LayoutInflater.inflate(LayoutInflater.java:500) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.view.LayoutInflater.inflate(LayoutInflater.java:410) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.view.LayoutInflater.inflate(LayoutInflater.java:361) 09-30 19:46:52.441: E/AndroidRuntime(11420): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350) 09-30 19:46:52.441: E/AndroidRuntime(11420): at android.app.Activity.setContentView(Activity.java:2122)

and for the code i chrashed after i added the xml line(i replaced the support v4 drawer)

<uk.me.lewisdeane.lnavigationdrawer.NavigationListView android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent">

content in here

</uk.me.lewisdeane.lnavigationdrawer.NavigationListView>

liamcottle commented 10 years ago

You're getting this error because you're setting the navigation list view as the root view. You need to create a navigation drawer, and use the NavigationListView inside of it.

Here's an example:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <!-- The main content view -->
    <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <!-- Put your layout design in here -->

    </FrameLayout>
    <!-- The navigation list view -->
    <uk.me.lewisdeane.lnavigationdrawer.NavigationListView
            android:id="@+id/navigation_list_view"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp"
            android:background="#FFFFFF"/>
</android.support.v4.widget.DrawerLayout>

You will need the Android Support library.