简体   繁体   English

如何在Android中添加卡片视图列表,并且只能通过滑动将其中一个视图移除?

[英]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.

相关问题 在android中获取可移动SD卡路径 - get removable sd card path in android 如何在Android的滑动页面中添加不同的内容 - how to add different content in swiping pages in android 如何从可移动 SD 卡中获取文件? - how to fetch files from removable SD card? 如何在java中从android的可移动存储(SD卡)获取所有pdf文件的链接? - How to get links to all pdf files from removable storage(SD Card) of android in java? 如何在android中找到内部(默认手机存储)和外部存储(可移动SD卡)? - How to find Internal(Default Phone Storage ) and External Storage(Removable sd card) in android? 如何在Android模拟器中模拟真正的外部SD(更新:可移动存储)卡 - how to emulate a real external sd (update: removable storage) card in Android Emulator 如何在Android Studio的卡片视图中安排动画? - how to schedule animation on card views in android studio? 如何从可移动/辅助SD卡中删除文件 - How to remove A file from removable/secondary SD card 如何在android中创建两个固定大小的视图和一个跨越它们的视图? - how to create two fixed size views and one view spanned between them in android? 如何更新卡片视图列表中的特定文本视图 - How to update a specific Text view present inside a list of Card Views
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM