[英]How to add a list of card views in Android with only one of them removable by swiping?
I'm trying to make a card list on the Main Activity of my app, and I want the user to have the ability to delete the first card, as it is only informative. 我正在尝试在应用程序的“主要活动”中列出卡片,并且希望用户能够删除第一张卡片,因为这仅是提供信息。 The rest of the cards would then open layouts that correspond to them.
然后,其余的卡将打开与它们相对应的布局。
Check Roman Nurik's Android-SwipeToDismiss: https://github.com/romannurik/Android-SwipeToDismiss 检查Roman Nurik的Android-SwipeToDismiss: https : //github.com/romannurik/Android-SwipeToDismiss
Implementation example is here: https://github.com/romannurik/Android-SwipeToDismiss/blob/master/src/com/example/android/swipedismiss/MainActivity.java 实现示例在此处: https : //github.com/romannurik/Android-SwipeToDismiss/blob/master/src/com/example/android/swipedismiss/MainActivity.java
Now in dismiss callback enable dismiss only on the first element. 现在在dismiss回调中仅在第一个元素上启用dismiss。
new SwipeDismissListViewTouchListener.DismissCallbacks() {
@Override
public boolean canDismiss(int position) {
return position == 0;
}
...
});
Not sure if the second element becomes the one at the position 0. If that's so you also need to track if the header was dismissed. 不知道第二个元素是否在位置0处变成一个。如果是这样,则还需要跟踪是否已删除标题。 Anyways, you can start from this and work it out.
无论如何,您可以从此开始并解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.