我是Android的新手,我第一次使用导航抽屉。我想我有些搞砸了。当我打开我的应用程序时,我的主要活动XML布局上的字段显示正常。但是,当我选择导航抽屉时,它出现在主窗体后面,看起来是半透明的。我无法选择导航抽屉上的任何选项。
我是否需要将mainActivity.java和mainactivity.xml上的UI和相关代码移动到片段中并默认加载?我的mainactivity.xml有问题吗?
谢谢,
杰里
<!-- 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="com.developer.symptom.androidclient.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.developer.symptom.androidclient.NavigationDrawerFragment" />
<!-- views used by main activity -->
<LinearLayout android:layout_width="fill_parent" android:layout_height="match_parent"
android:orientation="vertical" android:visibility="gone">
<!-- Welcome message -->
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginLeft="40dp"
android:textSize="20dp" android:text="Welcome"
android:id="@+id/main_welcome"/>
<!-- Data of birth and medical record number -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content" android:layout_marginLeft="15dp"
android:layout_height="wrap_content"
android:text="@string/date_of_birth_prompt"/>
<TextView
android:layout_width="wrap_content" android:layout_marginLeft="5dp"
android:layout_height="wrap_content" android:id="@+id/main_date_of_birth"/>
<TextView
android:layout_width="wrap_content" android:layout_marginLeft="25dp"
android:layout_height="wrap_content"
android:text="@string/med_rec_number_prompt"/>
<TextView
android:layout_width="wrap_content" android:layout_marginLeft="5dp"
android:layout_height="wrap_content" android:id="@+id/main_med_rec_num"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>