ListView滑動菜單,listview滑動

來源:互聯網
上載者:User

ListView滑動菜單,listview滑動

項目中使用到了listview中item滑動效果,找了幾個,最後發個一個很不錯的Swipemenulistview,記錄下來,以備後用

github上的一個開源庫,非常好用,git地址:https://github.com/baoyongzhang/SwipeMenuListView

使用方法也很簡單

運行效果:



使用說明:

將Swipemenulistview添加到xml中:

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


建立一個SwipeMenuCreator來添加功能表項目:

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);


添加點擊事件的Listener:


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;    }});


參考:http://blog.csdn.net/jerehedu/article/details/45196203

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.