我已经在这里经历了类似的问题和他们的解决方案,但花了几个小时后,我无法解决我的问题。我查看了许多解决方案,尝试了它们,但仍无法看到屏幕上的导航抽屉。如果有人能告诉我我在这里错过了什么,我将非常感激。无法看到导航抽屉
在此先感谢。
这里是我的xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="400dp"
android:layout_height="400dp"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/content_frame" >
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".Menu">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#fff"
android:text="test"
android:id="@+id/text" />
</RelativeLayout>
<ListView
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:choiceMode="singleChoice"
android:background="#fff"
android:id="@+id/left_drawer" >
</ListView>
</android.support.v4.widget.DrawerLayout>
这里是我的Menu.java:
>public class Menu extends AppCompatActivity {
>
> public DrawerLayout dlayout;
> public ListView flist;
> public String[] menu;
> //public ArrayAdapter<String> mAdapter;
>
> @Override
> protected void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.activity_menu);
>
> menu = getResources().getStringArray(R.array.nav_drawer_items);
> dlayout = (DrawerLayout) findViewById(R.id.drawer_layout);
> flist = (ListView) findViewById(R.id.left_drawer);
>
> flist.setAdapter(new ArrayAdapter<String>(this, R.layout.activity_menu, >R.id.text, menu));
> }
>}
我没有看到任何输出。 Screen output
你必须建立在最上面的左下角菜单图标。你必须为图标编码,当你点击该图标时,抽屉会打开/关闭。 –
谢谢达里尔。我正在执行您的建议。 – DK15