私はFragment
を開いている画像のうち4画像とonClick
からなるActivity
を持っています。また、私はNavigation Drawer
を持っています。ここでプロファイルオプションはfragment
です。私のProfileFragment
のフィールドは少ないので、空きスペースがあります。また、ユーザが空きスペースをクリックすると、Activity
に置かれた画像のクリックイベントが実行され、そのうちのFragment
が開きます。 profilefragment
の背景色をwhite
に設定しようとしましたが、動作しませんでした。フラグメント内の空きスペースをクリックすると、アクティビティイベントが実行されます
ProfileFragmentクラス:私はフラグメントを開くために次の行を使用していNavigation Drawer
のプロファイルオプションをクリックするだけで
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>
:
fragment = new ProfileFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.container_view,fragment).addToBackStack("Profile").commit();
この問題を解決するにはどうすればよいですか?親切に..アウトしてください
可能な重複[ビューをクリック背後に無効にする方法イベントFramelayout](http://stackoverflow.com/questions/16377593/how-to-disable-behind-view-click-event-framelayout) –