【发布时间】:2014-07-17 17:42:08
【问题描述】:
我开发了一个应用程序,该应用程序具有导航抽屉和抽屉内的许多片段,因此当我在片段内打开片段时遇到问题,在一个片段中,当用户单击列表视图项时,我有列表视图,他们获取与列表项相关的数据,所以我面临问题,它仍然点击不可见但点击的列表
片段布局
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:clickable="true"
android:background="@drawable/backgroung"
android:id="@+id/content_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"></FrameLayout>
<LinearLayout
android:id="@+id/linearDrawer"
android:layout_width="@dimen/dp260"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white"
android:layout_gravity="start">
<RelativeLayout
android:id="@+id/userDrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:layout_margin="@dimen/dp10">
打开片段的代码
Fragment fragment = new FragmentContactDetails();
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
transaction.add(((ViewGroup) getView().getParent()).getId(), fragment);
transaction.addToBackStack(null);
transaction.commit();
Bundle args = new Bundle();
int index = adapter.arrayList.indexOf(adapter.propertyList.get(position));
args.putInt(Constant.POSITION, index);
Toast.makeText(getActivity(), "" + index + "----" + adapter.propertyList.get(position).getName(), Toast.LENGTH_LONG).show();
fragment.setArguments(args);
【问题讨论】:
-
添加 transaction.commit();在 fragment.setarguments 之后的最后一行
标签: android android-fragments android-fragmentactivity