VastSwipeListView

A support for custom copy QQ list sliding controls

Dizzy: features

  • 🤔 Supports custom menu items, includingThe title icon Menu background color Title font size Size of the icon
  • 🤣 supports custom menu categories, includingLeft menu only Right menu only There are menus left and right
  • 😏 Supports custom menu opening and closing time
  • 😎 Supports custom menusInterpolator
  • 😛 provides initial values for better compatibility
  • 😁 Separate design, useVastSwipeMenuMgrStyle management
  • 🙂 use menu items to define menu click events to avoid interface design that requires you to write if decisions repeatedly

🛠 Quick start

  1. Add VastSwipeListView to your layout

    
            
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".SlideActivity">
        <com.gcode.vastswipelayout.view.VastSwipeListView
            android:id="@+id/listview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:choiceMode="singleChoice"/>
    </LinearLayout>
    Copy the code
  2. Define your menu item with VastSwipeMenuItem, and add the menu item to it by calling the method in VastSwipeMenuMgr

    Let’s take defining an undo item as an example

    val deleteItem = VastSwipeMenuItem(this@SlideActivity)
    deleteItem.setBackgroundByColorInt(0xFF1e90ff)
    deleteItem.setTitleByString("Cancel")
    deleteItem.setTitleColorByColorInt(Color.WHITE)
    deleteItem.setIconByResId(R.drawable.ic_delete)
    deleteItem.setClickEvent { item: VastSwipeMenuItem, position: Int ->
        run {
            Toast.makeText(this@SlideActivity."${item.title} $position", Toast.LENGTH_SHORT)
                .show()
        }
    }
    
    swipeMenuMgr.addLeftMenuItem(deleteItem)
    Copy the code
  3. Prepare the adapter for the list item data

    val listViewAdapter = ListViewAdapter(this, R.layout.listview_item, lists)
    Copy the code
  4. Pass the set VastSwipeMenuMgr and list item Adapter to VastSwipeListView

    vastSwipeListView.setSwipeMenuMgr(swipeMenuMgr)
    vastSwipeListView.adapter = listViewAdapter
    vastSwipeListView.onItemClickListener =
        AdapterView.OnItemClickListener { _, _, arg2, _ ->
            Toast.makeText(
                context,
                "Position" + arg2 + ">>> Value:" + lists[arg2],
                Toast.LENGTH_SHORT
            ).show()
        }
    Copy the code

👀 View the code

👉 VastSwipeListView