Android侧滑库AndroidSwipeLayout使用示例
来源:互联网 发布:js li取消隐藏 编辑:程序博客网 时间:2024/05/18 15:04
github 开源项目:AndroidSwipeLayou
继承 BaseSwipwAdapter ,在 item布局中 使用 swipeLayout
public class ConversationListAdapter extends BaseSwipeAdapter { private Context context; private ArrayList<ConDoctor> list; private LayoutInflater inflater; public ConversationListAdapter(Context context, ArrayList<ConDoctor> list) { this.context = context; this.list = list; this.inflater = LayoutInflater.from(context); } @Override public int getCount() { return list.size(); } @Override public Object getItem(int position) { return list.get(position); } @Override public long getItemId(int position) { return position; } @Override public int getSwipeLayoutResourceId(int i) { return R.id.conlist_item_swipe; } //创建 布局 @Override public View generateView(final int i, ViewGroup viewGroup) { View v = inflater.inflate(R.layout.adapter_conversationlist, viewGroup, false); final SwipeLayout swipeLayout = (SwipeLayout) v.findViewById(getSwipeLayoutResourceId(i)); swipeLayout.setDragEdge(SwipeLayout.DragEdge.Right); swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown); swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() { @Override public void onStartOpen(SwipeLayout swipeLayout) { LogUtil.i("qqq---onStartOpen"+i); } @Override public void onOpen(SwipeLayout swipeLayout) { LogUtil.i("qqq---onOpen"+i); } @Override public void onStartClose(SwipeLayout swipeLayout) { LogUtil.i("qqq---onStartClose"+i); } @Override public void onClose(SwipeLayout swipeLayout) { LogUtil.i("qqq---onClose"+i); } @Override public void onUpdate(SwipeLayout swipeLayout, int i, int i1) { LogUtil.i("qqq--onUpdate"+i); } @Override public void onHandRelease(SwipeLayout swipeLayout, float v, float v1) { LogUtil.i("qqq--onHandRelease"+i); } }); swipeLayout.addOnLayoutListener(new SwipeLayout.OnLayout() { @Override public void onLayout(SwipeLayout swipeLayout) { LogUtil.i("qqq--onLayout"+i); } }); v.findViewById(R.id.conlist_item_del).setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { } }); return v; } //加载 数据 @Override public void fillValues(int position, View v) { ImageView img = (ImageView) v.findViewById(R.id.conlist_item_img); TextView name = (TextView) v.findViewById(R.id.conlist_item_tvName); TextView status = (TextView) v.findViewById(R.id.conlist_item_tvStatus); TextView time = (TextView) v.findViewById(R.id.conlist_item_tvTime); // ConDoctor con = list.get(position); name.setText(con.getDoctor_name()); BmpHelper.loadCircleBmp(img, con.getHeaderImg()); status.setText(StrHelper.getStatus(con.getStatus())); String strTime = ""; if (con.getCreate_time().length() >= 16) { strTime = con.getCreate_time().substring(0, 16); } time.setText(strTime); }
<?xml version="1.0" encoding="utf-8"?><com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:swipe="http://schemas.android.com/tools" android:id="@+id/conlist_item_swipe" android:layout_width="match_parent" android:layout_height="wrap_content" swipe:leftEdgeSwipeOffset="0dp" swipe:rightEdgeSwipeOffset="0dp"> <!--滑出的 按钮--> <LinearLayout android:layout_width="60dp" android:layout_height="68dp" android:orientation="horizontal"> <ImageView android:id="@+id/conlist_item_del" android:layout_width="40dp" android:layout_height="match_parent" android:src="@mipmap/ic_launcher" /> </LinearLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white"> <ImageView android:id="@+id/conlist_item_img" android:layout_width="55dp" android:layout_height="55dp" android:layout_marginLeft="16dp" android:layout_marginTop="15dp" android:src="@mipmap/ic_launcher" /> <TextView android:id="@+id/conlist_item_tvName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginTop="20dp" android:layout_toRightOf="@id/conlist_item_img" android:text="医生名称" android:textColor="@color/black_b" android:textSize="16sp" /> </RelativeLayout></com.daimajia.swipe.SwipeLayout>
0 1
- Android侧滑库AndroidSwipeLayout使用示例
- AndroidSwipeLayout库的使用
- Android UI Libs之AndroidSwipeLayout
- Android 动效系列之一 - AndroidSwipeLayout
- 在使用AndroidSwipeLayout发现的一些问题
- AndroidSwipeLayout源码
- AndroidSwipeLayout 分析
- AndroidSwipeLayout理解
- android 使用vcard示例
- Android Services使用示例
- android LayoutInflater 使用示例
- android 使用vcard示例
- Android SQLiteOpenHelper使用示例
- android 使用vcard示例
- android 使用vcard示例
- android SQLiteOpenHelper使用示例
- android SQLiteOpenHelper使用示例
- Android 使用Loader示例
- Java集合---Arrays类源码解析
- Spring 事务管理
- 桂微盘 开启6元微交易投资新时代
- 火狐Firefox最简洁界面设置
- 如何在jsp页面调用的java类中获取当前线程的request和session
- Android侧滑库AndroidSwipeLayout使用示例
- Java集合---ConcurrentHashMap原理分析
- 微信成长
- HDU-1847-Good Luck in CET-4 Everybody!【巴什博弈】
- 基于MySQL游标的具体使用详解
- easyUI中index的使用
- Java中TCP的简单使用
- Unity5 新AssetBundle打包方式 BuildPipeline.BuildAssetBundles
- 求斐波那契数的栈模拟递归算法