我有一个recyclerview
,其中包含imageview
,textview
和floating action button
我已附加addOnItemTouchListener
事件以导航到fullscreen view
}。除此之外,click event
内的floating action button
附加了recyclerview
。
recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(), recyclerView, new GalleryAdapter.ClickListener() {
@Override
public void onClick(View view, int position) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance();
newFragment.show(ft, "slideshow");
}
@Override
public void onLongClick(View view, int position) {
}
}));
以下是FAB
内的RecyclerView
<android.support.design.widget.FloatingActionButton
android:id="@+id/select_cake"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:descendantFocusability="blocksDescendants"
app:fabSize="normal"
app:layout_anchorGravity="top|right|end" />
</android.support.design.widget.CoordinatorLayout>
在clickevent
中和GalleryAdapter
view.findViewById(R.id.select_cake).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mContext,"Test Toast",Toast.LENGTH_LONG).show();
}
});
但是,每当我点击FAB
时,就会显示toast,但它也会通过recyclerView's ItemTouchListner
我已将android:descendantFocusability="blocksDescendants"
和android:clickable="true"
用于FAB
,但该事件仍会导航到其父recyclerView
,从而为recyclerItemClick
执行代码行}。我该如何防止这种行为?