Raj*_*eev 3 android android-fragments android-activity
我有一个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;
}
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
单击中的配置文件选项后,Navigation Drawer我使用以下行打开片段:
fragment = new ProfileFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.container_view,fragment).addToBackStack("Profile").commit();
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?请帮帮我吧..
将此代码写入片段的根布局中
android:clickable="true"
Run Code Online (Sandbox Code Playgroud)
你的情况是FrameLayout这样
<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"
android:clickable="true"
tools:context="com.six30labs.mis.fragments.ProfileFragment">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
985 次 |
| 最近记录: |