【发布时间】:2014-10-13 07:11:20
【问题描述】:
我在我的 android 应用程序上工作,我想创建一个带有滑动子视图的视图。子视图将包含一些小部件,例如 EditText。这是我的布局文件。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="start"
android:background="#0000ff">
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
</FrameLayout>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
我无法在 EditText 小部件之间切换。当我单击某个小部件时,滑动布局开始折叠。我认为这是我的问题的原因,但我使用以下代码。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
DrawerLayout drawerLayout = (DrawerLayout) view.findViewById(R.id.drawer_layout);
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
return view;
}
左侧布局已锁定,但我仍然无法在小部件之间切换。我也尝试更改可点击和可聚焦的属性。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
DrawerLayout drawerLayout = (DrawerLayout) view.findViewById(R.id.drawer_layout);
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
drawerLayout.setClickable(true);
drawerLayout.setFocusable(true);
return view;
}
有什么想法吗?
【问题讨论】:
标签: android android-widget navigation-drawer