2016-11-10 5 views
2

私は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(); 

この問題を解決するにはどうすればよいですか?親切に..アウトしてください

+0

可能な重複[ビューをクリック背後に無効にする方法イベントFramelayout](http://stackoverflow.com/questions/16377593/how-to-disable-behind-view-click-event-framelayout) –

答えて

1

書き込み、それはFrameLayoutであなたのケースで

android:clickable="true" 

あなたのフラグメントのルートレイアウトでこのコードを私を助けるので

<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"> 
+1

ねえありがとう!それは問題を解決しました!確かにそれについて読むでしょう:) – Rajeev

関連する問題