【发布时间】:2016-11-10 06:48:21
【问题描述】:
我有一个Activity,它由 4 张图片和onClick 组成,我正在打开一个Fragment。另外,我有一个Navigation Drawer,其中配置文件选项打开了一个fragment。由于我的ProfileFragment 中的字段很少,因此分配了空白空间。如果用户单击空白区域,则执行放置在Activity 中的图像的单击事件,并打开特定的Fragment。我尝试将profilefragment 的背景颜色设置为white,但没有成功。
ProfileFragment 类:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_profile, container, false);
ButterKnife.bind(this, view);
view.setBackgroundColor(Color.WHITE);
return view;
}
profile_fragment.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.six30labs.mis.fragments.ProfileFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/empCompanyName"
style="@style/MyTextViewStyle"
android:hint="Company Name"
android:inputType="text" />
<EditText
android:id="@+id/empPhoneNumber"
style="@style/MyTextViewStyle"
android:hint="Employee PhNo"
android:inputType="text" />
<EditText
android:id="@+id/empEmail"
style="@style/MyTextViewStyle"
android:hint="Employee Email"
android:inputType="text" />
<Button
android:id="@+id/editProfileBtn"
android:text="Edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</FrameLayout>
单击Navigation Drawer 中的配置文件选项时,我使用以下行打开片段:
fragment = new ProfileFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.container_view,fragment).addToBackStack("Profile").commit();
我该如何解决这个问题?请帮帮我..
【问题讨论】:
标签: android android-fragments android-activity