<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=".MainActivity">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<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"
android:name="com.fragment.NavigationDrawerFragment" />
</android.support.v4.widget.DrawerLayout>
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
这里的主要问题是:上面的代码在几乎所有的设备(受刺激的设备,或者一些真实的设备)上都能顺利运行。但当我在三星S3上运行时。它注意到这个错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{view.MainActivity}: android.view.InflateException: Binary XML file line #25: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2081)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2106)
at android.app.ActivityThread.access$700(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1217)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4856)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316)
at android.app.Activity.setContentView(Activity.java:1901)
at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:208)
at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:111)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
请告诉我如何修复错误,谢谢:)
经过长时间的调试,我已经解决了这个问题。(虽然我还无法解释原因)。将属性android:name
更改为class
。(虽然在Android文档上,他们说那些属性是一样的,但它起作用了!!!)
因此,它应该从:
android:name="com.fragment.NavigationDrawerFragment"
至
class = "com.fragment.NavigationDrawerFragment"
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<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 = "com.fragment.NavigationDrawerFragment" />
当我点击后退按钮并返回到位置片段时,我遇到了一些问题,下面出现了一个错误: 我确实查了很多帖子,尝试了所有的解决方案,但它不起作用。似乎其他菜单项不是问题,只是这个位置页面给出了一个错误。 fragment_location.xml LocationFragment.java
这里是MainActivity类 我的LogCat文件是 求你了,救命
我刚刚实现了我的第四个选项卡到我的应用程序中,已经实现了谷歌地图。在此实现之前,我的应用程序运行良好,但现在当我更改选项卡时,它会崩溃。我在这里看到过类似的问题,但没有一个有答案(实际上有这么多不同的原因和回应这个问题) 下面是fragmentshouts_maps类 查看寻呼机适配器类 这是我的错误日志
“Android.View.InflateException:二进制XML文件行#54:Error inflating class EditText”是在由于项目而完成登录屏幕并运行时生成的。我怎么解决这个?