Tôi có một bố trí RecyclerView
hàng như thế nàyRecyclerView Vuốt bằng một cái nhìn dưới đây không phát hiện nhấp
<Layout>
<BackgroundView>
<ForegroundView>
</Layout>
Tôi đang sử dụng ItemTouchHelper
để xử lý thao tác vuốt (một phần) trên quan điểm foreground như
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
adapter.onItemSwiped(viewHolder);
}
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
float dX, float dY, int actionState, boolean isCurrentlyActive) {
View foregroundView = ((myViewHolder)viewHolder).getForegroundView();
getDefaultUIUtil().onDraw(c, recyclerView, foregroundView, dX, dY, actionState, isCurrentlyActive);
//getSwipeLimit() used below returns the width of the delete icon
float translationX = Math.min(-dX, ((myViewHolder) viewHolder).getSwipeLimit());
foregroundView.setTranslationX(-translationX);
}
tôi đã đặt trình nghe nhấp chuột cho chế độ xem nền trong lớp BindViewHolder
của lớp bộ điều hợp của tôi.
@Override
public void onBindViewHolder(WhiteListViewHolder holder, Cursor cursor) {
//get name and number from the cursor here
holder.name.setText(name);
holder.number.setText(number);
holder.deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("whitelist", "yes clicked");
}
});
}
Vấn đề là, quan điểm nền được chấp nhận nhấp chuột khi xem không swiped nhưng sau khi xem được swiped ra, quan điểm nền dừng chấp nhận nhấp chuột.
Nhắc hình trên, nếu tôi bấm vào nút delete, quan điểm swiped bị thu hồi và đôi khi nó không nắm bắt được nhấp chuột.
Nếu tôi để toàn bộ chế độ xem trượt ra ngoài, việc nhấp vào khoảng trống còn lại cũng sẽ hiển thị lại chế độ xem được vuốt.
Xin cảm ơn trước.
Bạn có thể chia sẻ dự án của mình trong Github để tôi có thể dùng thử không? –
@ReazMurshed Bạn có thể tìm thấy dự án tại đây: https://github.com/amk47/testproject – AMK
Thanh toán thư viện này: Đây là những gì tôi đã sử dụng trong một dự án, nó hoạt động hoàn hảo cho tôi. Hãy cho tôi biết nếu nó giúp: https://github.com/daimajia/AndroidSwipeLayout –