android.view.InflateException:二进制XML文件第7行:膨胀类工具栏时出错 [英] android.view.InflateException: Binary XML file line #7: Error inflating class Toolbar
本文介绍了android.view.InflateException:二进制XML文件第7行:膨胀类工具栏时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过android.support.v7
库使用ToolBar
(棒棒糖窗口小部件).
I am trying to use ToolBar
(Lollipop Widget) using android.support.v7
library.
但是在运行应用程序时出现错误.
But while running an app getting an error.
android.view.InflateException: Binary XML file line #7: Error inflating class Toolbar
我的主要目标是使用toolbar
创建navigation drawer
.
My main goal is to have a navigation drawer
using toolbar
.
这是我正在使用的布局文件:
This is the Layout file which i am using :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame_container1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Toolbar android:id="@+id/toolbar" <------ line #7
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/status" ></Toolbar>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >
<!-- Framelayout to display Fragments -->
<RelativeLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<!-- Listview to display slider menu -->
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:dividerHeight=".02dp"
android:background="#000000"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
我正在使用以下代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, new String[]{""});
//mDrawerList.setAdapter(adapter);
t=(Toolbar) findViewById(R.id.toolbar);
//getActionBar().setDisplayHomeAsUpEnabled(true);
//getActionBar().setHomeButtonEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.string.app_name, // nav drawer open - description for accessibility
R.string.app_name // nav drawer close - description for accessibility
) {
public void onDrawerClosed(View view) {
// calling onPrepareOptionsMenu() to show action bar icons
// invalidateOptionsMenu();
super.onDrawerClosed(view);
}
public void onDrawerOpened(View drawerView) {
super.onDrawerClosed(drawerView);
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
请帮助.
推荐答案
使用
<android.support.v7.widget.Toolbar />
代替
<Toolbar />
这篇关于android.view.InflateException:二进制XML文件第7行:膨胀类工具栏时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文