daimajia / daimajia/AndroidSwipeLayout
Layout automatically close when button clicked
- Dominant language
- Java
- Stars
- 12.3k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
I have two buttons on my swipe layout. they both increment and decrement an integer value whenever they are clicked. But after i click one of the button, the layout close automatically. What is wrong with my code?
Here's some screenshoot :

Swipe layout xml :
My itemholder class :
public class MenuItemHolder extends RecyclerView.ViewHolder {
public SwipeLayout swipeLayout;
public TextView foodName,price,qtyOrdered;
public Button plusBtn,minusBtn;
private int qtyContainer = 1;
// public ImageView imgSrc;
public MenuItemHolder(View view) {
super(view);
plusBtn = view.findViewById(R.id.plus_btn);
minusBtn = view.findViewById(R.id.minus_btn);
qtyOrdered = itemView.findViewById(R.id.qty_ordered);
foodName = view.findViewById(R.id.menu_name);
price = view.findViewById(R.id.price);
// imgSrc = view.findViewById(R.id.bg_food);
swipeLayout = view.findViewById(R.id.swipe);
swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);
//dari kiri
swipeLayout.addDrag(SwipeLayout.DragEdge.Right, swipeLayout.findViewById(R.id.bottom_wrapper));
swipeLayout.addDrag(SwipeLayout.DragEdge.Left, null);
plusBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
qtyContainer++;
qtyOrdered.setText(String.valueOf(qtyContainer));
swipeLayout.open();
}
});
minusBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
qtyContainer--;
if(qtyContainer < 1){
qtyContainer = 1;
}
qtyOrdered.setText(String.valueOf(qtyContainer));
swipeLayout.open();
}
});
}
}
Any help will be appreciated. Thanks :)
UPDATE :
The main problem is the setText method which makes the swipe layout close. so, where should i put the setText method?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.