0

私のアプリでRecyclerViewよりFloatingActionButtonがあります。 Buttonが表示されていますが、そのボタンをクリックすると、ボタンの代わりにRecyclerViewアイテムの下にクリックイベントが表示されます。 RecyclerViewFloatingActionButtonに表示するように設定すると、Buttonは意図したとおりに動作します。RecyclerView項目AndroidでFloatingActionButtonをクリックするとクリックされる

これを解決するには、Buttonをクリックイベントにするにはどうすればいいですか?

ありがとうございます。

+0

相対レイアウトやのLinearLayout内FABを入れて.... FloatingActionButtonあなたの問題が解決されます上のonClickリスナを設定し、そのレイアウトプロパティをandroid:clickable = "true"に設定してください。 android:focusableInTouchMode = "true"とその完了です。 –

+0

Fab.bringToFront()とclickableを追加:xmlでtrue –

+0

皆さんありがとうございます。 – Fustigador

答えて

0

画面には、FrameLayoutを使用します。すべてのクリックイベント、アイテム、またはフローティングボタンを取得できます。

<FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@android:color/white"> 
<android.support.v7.widget.RecyclerView 
     android:id="@+id/recyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
    </android.support.v7.widget.RecyclerView> 
<android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@android:drawable/ic_dialog_email" /> 
</FrameLayout> 
0

あなたはFloatingActionButton上のonClickリスナを設定しない場合にのみ発生する可能性があります。だから

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 
fab.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      //Your code to do something if you have 
     } 
}); 
ちょうど上記のような空のリスナーを実装行うためのアクションを持っている場合は

...

関連する問題