日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Android仿ios微信左划条目删除、置顶的实现,代码简洁,更容易理解使用

發布時間:2024/1/8 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android仿ios微信左划条目删除、置顶的实现,代码简洁,更容易理解使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

<span style="font-family:Arial, Helvetica, sans-serif;"><span style="background-color: rgb(255, 255, 255);">歡迎大家</span></span> <span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">首先看一下效果圖(內容比較糙,還請大家擔待)</span>


實現刪除功能


實現置頂功能



實現的邏輯代碼很簡單,如下:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 mListView.setAdapter(listAdapter); SwipeMenuCreator creator = new SwipeMenuCreator() { @Override public void create(SwipeMenu menu) { // 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(DensityUtils.dp2px(MainActivity.this, 60)); // set a icon deleteItem.setIcon(R.drawable.ic_delete); // add to menu menu.addMenuItem(deleteItem);
// create "top" item SwipeMenuItem topItem = new SwipeMenuItem( getApplicationContext()); // set item background topItem.setBackground(new ColorDrawable(Color.BLUE)); // set item width topItem.setWidth(DensityUtils.dp2px(MainActivity.this, 60)); topItem.setTitle("置頂"); topItem.setTitleSize(20); topItem.setTitleColor(Color.WHITE); // add to menu menu.addMenuItem(topItem); } }; mListView.setMenuCreator(creator); mListView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(int position, SwipeMenu menu, int index) { switch (index) { case 0: items.remove(position); listAdapter.notifyDataSetChanged(); break; case 1: String str=items.get(position); items.remove(position); items.add(0,str); listAdapter.notifyDataSetChanged(); Toast.makeText(getApplicationContext(), "置頂成功", Toast.LENGTH_SHORT).show(); break; } return false; } });

實現起來很容易的,直接下載源碼就可以使用:http://download.csdn.net/detail/ya977896216/9576796

總結

以上是生活随笔為你收集整理的Android仿ios微信左划条目删除、置顶的实现,代码简洁,更容易理解使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。