无法使用AndroidDrawer(像facebook一样的侧边栏)

2024-03-22

我正在尝试使用这个AndroidDrawer侧边栏库。 https://bitbucket.org/verdigo/drawer根据说明,以下是我在 mainactivity 中的代码。代码崩溃并显示应用程序“已停止 - 强制关闭”消息

公共类 MainActivity 扩展 Activity {

Drawer mDrawer;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);     
    setContentView(R.layout.activity_main);     
    mDrawer = Drawer.createLeftDrawer(this, R.layout.drawer_content);
    mDrawer.init();     
    mDrawer.show();
}   
}

下面是我的抽屉内容.xml- 非常简单,只是一个文本视图:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >


<TextView
    android:id="@+id/tv_drawer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:text="Textview in drawer ... "
    android:inputType="textPostalAddress" >

</TextView>

</LinearLayout>

The 活动_main.xml也是一个简单的 Textview:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:text="asdsadd"
    android:inputType="textPostalAddress" >

</TextView>

</LinearLayout>

第一件事;为此不需要图书馆。

有一个非常简单的实现。看看这个教程:

http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/ http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/

另外,看看这篇文章:看看你是否想要这样的东西:

在导航抽屉片段内滑动选项卡 https://stackoverflow.com/questions/22389933/swiping-tabs-inside-a-navigation-drawer-fragment/22391553#22391553

如果您想要此处的完整代码,请告诉我。

祝你好运 .. :)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法使用AndroidDrawer(像facebook一样的侧边栏) 的相关文章

随机推荐