Project to use the item in the ListView slide effect, find a few, finally sent a very good Swipemenulistview, recorded, for later use
An open source library on GitHub, very handy, git address: Https://github.com/baoyongzhang/SwipeMenuListView
The use of the method is also very simple
Operating Effect:
Instructions for use:
Add the Swipemenulistview to the XML:
<com.baoyz.swipemenulistview.swipemenulistview android:id= "@+id/listview" android:layout_width= " Match_parent " android:layout_height=" Match_parent "/>
Create a swipemenucreator To add a menu item:
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 listener to the Click event:
listView.setOnMenuItem Clicklistener (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; }});
|
Reference: http://blog.csdn.net/jerehedu/article/details/45196203 |
ListView Slide Menu