ListView sliding menu, listview sliding

Source: Internet
Author: User

ListView sliding menu, listview sliding

The item slide effect in the listview is used in the project. I found a few items, and finally sent a very good Swipemenulistview, and recorded it for later use.

Github on an open source library, very useful, git address:

Easy to use

Running effect:

Instructions for use:

Add Swipemenulistview to xml:

<com.baoyz.swipemenulistview.SwipeMenuListView        android:id="@+id/listView"        android:layout_width="match_parent"        android:layout_height="match_parent" />

Create a SwipeMenuCreator to add menu items:

SwipeMenuCreator creator = new SwipeMenuCreator() {    @Override    public void create(SwipeMenu menu) {        // create "open" item        SwipeMenuItem openItem = new SwipeMenuItem(                getApplicationContext());        // set item background        openItem.setBackground(new ColorDrawable(Color.rgb(0xC9, 0xC9,                0xCE)));        // set item width        openItem.setWidth(dp2px(90));        // set item title        openItem.setTitle("Open");        // set item title fontsize        openItem.setTitleSize(18);        // set item title font color        openItem.setTitleColor(Color.WHITE);        // add to menu        menu.addMenuItem(openItem);        // create "delete" item        SwipeMenuItem deleteItem = new SwipeMenuItem(                getApplicationContext());        // set item background        deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9,                0x3F, 0x25)));        // set item width        deleteItem.setWidth(dp2px(90));        // set a icon        deleteItem.setIcon(R.drawable.ic_delete);        // add to menu        menu.addMenuItem(deleteItem);    }};// set creatorlistView.setMenuCreator(creator);

Add the Listener of the click event:

listView.setOnMenuItemClickListener(new OnMenuItemClickListener() {    @Override    public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {        switch (index) {        case 0:            // open            break;        case 1:            // delete            break;        }        // false : close the menu; true : not close the menu        return false;    }});


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.