【发布时间】:2014-08-05 01:54:55
【问题描述】:
我在我的主要活动中使用活动。我想通过点击我的主要意图上的按钮从我的主要活动转到导航抽屉活动。
我从 android studio 中的 navdrawer-wizard 创建了导航抽屉。
但是当我点击按钮时出现错误。
我使用 Api 级别 10。Android 支持库 v7、v4 也在我的项目中。
我使用 Android 工作室。
我已经调试了这个问题,它触发了启动活动但是它在 logcat 中出现了这样的错误。
java.lang.RuntimeException: Unable to start activity ComponentInfo{www.epicmyanmar.com.andropos/www.epicmyanmar.com.andropos.MyActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class fragment
任何帮助或任何建议都将是 appricieate
`
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
` `<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"
tools:context="www.epicmyanmar.com.andropos.MyActivity">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
`enter code here`<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
If you're not building against API 17 or higher, use
android:layout_gravity="left" instead. -->
<!-- The drawer is given a fixed width in dp and extends the full height of
the container. -->
<fragment android:id="@+id/navigation_drawer"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
class="www.epicmyanmar.com.andropos.NavigationDrawerFragment"
tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>`
【问题讨论】:
-
您的错误在导航抽屉 xml 文件中
-
您是否在 AndroidManifest.xml 中声明了您的活动?
-
是的,我已经声明了
-
有没有可能?