android-swipelistview使用说明
来源:互联网 发布:祝利荣牛熊线指标源码 编辑:程序博客网 时间:2024/05/17 07:01
项目地址:https://github.com/47deg/android-swipelistview
参数说明:http://www.jcodecraeer.com/a/opensource/2014/1015/1777.html
代码来源:http://www.apkbus.com/android-143803-1-1.html
效果图
<com.fortysevendeg.swipelistview.SwipeListView xmlns:swipe="http://schemas.android.com/apk/res-auto" android:id="@+id/example_lv_list" android:listSelector="#00000000" android:layout_width="fill_parent" android:layout_height="wrap_content" swipe:swipeFrontView="@+id/front" swipe:swipeBackView="@+id/back" swipe:swipeActionLeft="[reveal | dismiss]" swipe:swipeActionRight="[reveal | dismiss]" swipe:swipeMode="[none | both | right | left]" swipe:swipeCloseAllItemsWhenMoveList="[true | false]" swipe:swipeOpenOnLongPress="[true | false]" swipe:swipeAnimationTime="[miliseconds]" swipe:swipeOffsetLeft="[dimension]" swipe:swipeOffsetRight="[dimension]" />
swipeFrontView
- Required - front view id.swipeBackView
- Required - back view id.swipeActionLeft
- Optional - left swipe action Default: 'reveal'swipeActionRight
- Optional - right swipe action Default: 'reveal'swipeMode
- Gestures to enable or 'none'. Default: 'both'swipeCloseAllItemsWhenMoveList
- Close revealed items on list motion. Default: 'true'swipeOpenOnLongPress
- Reveal on long press Default: 'true'swipeAnimationTime
- item drop animation time. Default: android configurationswipeOffsetLeft
- left offsetswipeOffsetRight
- right offset
中文:
swipeFrontView
- Required - front view id. 即ListView Item正常显示的控件Id,且必须与Item的布局文件中的控件id一样swipeBackView
- Required - back view id. 手指滑动时显示的,隐藏在FrontView后面,且必须与item的布局文件中控件Id一样swipeActionLeft
- Optional - left swipe action Default: 'reveal' 左滑的动作,默认reveal,即显示BackView,还有dismiss,choice会触发响应的方法。swipeActionRight
- Optional - right swipe action Default: 'reveal' 同上swipeMode
- Gestures to enable or 'none'. Default: 'both' 设置左滑、右滑、都支持swipeCloseAllItemsWhenMoveList
- Close revealed items on list motion. Default: 'true' 当滚动listview时,关闭所有展开的Item,最好不要设置为false,由于item的复用,false存在一些问题。swipeOpenOnLongPress
- Reveal on long press Default: 'true' 长按时触发显示swipeAnimationTime
- item drop animation time. Default: android configuration 动画时间长度swipeOffsetLeft
- left offset 左偏移量swipeOffsetRight
- right offset 右偏移量
MainActivity.java
import android.app.Activity;import android.os.Bundle;import android.widget.Toast;import com.fortysevendeg.swipelistview.BaseSwipeListViewListener;import com.fortysevendeg.swipelistview.SwipeListView;import java.util.ArrayList;import java.util.Arrays;import java.util.List;public class MainActivity extends Activity { private SwipeListView mSwipeListView ; private SwipeAdapter mAdapter ; public static int deviceWidth ; private List<String> testData ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSwipeListView = (SwipeListView) findViewById(R.id.example_lv_list); testData = getTestData(); mAdapter = new SwipeAdapter(this, R.layout.package_row, testData,mSwipeListView); deviceWidth = getDeviceWidth(); mSwipeListView.setAdapter(mAdapter); mSwipeListView.setSwipeListViewListener( new TestBaseSwipeListViewListener()); reload(); } private List<String> getTestData() { String [] obj = new String[]{"图震APP","看美女","看汽车","下载地址","小米市场","豌豆荚市场","每天更新","你要的不是我","不潮不用花钱","只对你有感觉","简简单单"}; List<String> list = new ArrayList<String>(Arrays.asList(obj)); return list; } private int getDeviceWidth() { return getResources().getDisplayMetrics().widthPixels; } private void reload() { mSwipeListView.setSwipeMode(SwipeListView.SWIPE_MODE_LEFT); mSwipeListView.setSwipeActionLeft(SwipeListView.SWIPE_ACTION_REVEAL);//mSwipeListView.setSwipeActionRight(settings.getSwipeActionRight()); mSwipeListView.setOffsetLeft(deviceWidth * 1 / 3);//mSwipeListView.setOffsetRight(convertDpToPixel(settings.getSwipeOffsetRight())); mSwipeListView.setAnimationTime(0); mSwipeListView.setSwipeOpenOnLongPress(false); } class TestBaseSwipeListViewListener extends BaseSwipeListViewListener{ @Override public void onClickFrontView(int position) { super.onClickFrontView(position); Toast.makeText(getApplicationContext(), testData.get(position), Toast.LENGTH_SHORT).show(); } @Override public void onDismiss(int[] reverseSortedPositions) { for (int position : reverseSortedPositions) { testData.remove(position); } mAdapter.notifyDataSetChanged(); } }}
SwipeAdapter.java
import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.View.OnClickListener;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.Button;import android.widget.TextView;import com.fortysevendeg.swipelistview.SwipeListView;import java.util.List;public class SwipeAdapter extends ArrayAdapter<String> {private LayoutInflater mInflater ;private List<String> objects ;private SwipeListView mSwipeListView ;public SwipeAdapter(Context context, int textViewResourceId,List<String> objects, SwipeListView mSwipeListView) {super(context, textViewResourceId, objects);this.objects = objects ;this.mSwipeListView = mSwipeListView ;mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);}@Overridepublic View getView(final int position, View convertView, ViewGroup parent) {ViewHolder holder = null ;if(convertView == null){convertView = mInflater.inflate(R.layout.package_row, parent, false);holder = new ViewHolder();holder.mFrontText = (TextView) convertView.findViewById(R.id.example_row_tv_title);holder.mBackEdit = (Button) convertView.findViewById(R.id.example_row_b_action_3);holder.mBackDelete = (Button) convertView.findViewById(R.id.example_row_b_action_2);convertView.setTag(holder);}else{holder = (ViewHolder) convertView.getTag();}holder.mBackDelete.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {mSwipeListView.closeAnimate(position);mSwipeListView.dismiss(position);}});String item = getItem(position);holder.mFrontText.setText(item);return convertView;}class ViewHolder{TextView mFrontText ;Button mBackEdit,mBackDelete ;}}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:swipe="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <com.fortysevendeg.swipelistview.SwipeListView android:id="@+id/example_lv_list" android:layout_width="match_parent" android:layout_height="match_parent" android:listSelector="#00000000" swipe:swipeActionLeft="reveal" swipe:swipeActionRight="reveal" swipe:swipeAnimationTime="0" swipe:swipeBackView="@+id/back" swipe:swipeCloseAllItemsWhenMoveList="true" swipe:swipeFrontView="@+id/front" swipe:swipeMode="both" swipe:swipeOffsetLeft="0dp" swipe:swipeOffsetRight="0dp" swipe:swipeOpenOnLongPress="false" /></RelativeLayout>
package_row.xml
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:id="@+id/back" android:layout_width="match_parent" android:layout_height="80dp" android:tag="back" android:background="#eee" > <Button android:id="@+id/example_row_b_action_1" android:layout_width="0dp" android:background="@null" android:layout_height="wrap_content" android:layout_weight="1" /> <Button android:id="@+id/example_row_b_action_2" android:layout_width="0dp" android:layout_marginLeft="10dp" android:layout_height="60dp" android:text="删除" android:layout_gravity="center" android:layout_weight="1" /> <Button android:id="@+id/example_row_b_action_3" android:layout_width="0dp" android:text="编辑" android:layout_gravity="center" android:layout_height="60dp" android:layout_weight="1" /> </LinearLayout> <RelativeLayout android:id="@+id/front" android:orientation="vertical" android:tag="front" android:background="#ffffff" android:layout_width="match_parent" android:layout_height="80dp" > <TextView android:id="@+id/example_row_tv_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:textSize="18sp" /> </RelativeLayout></FrameLayout>
下载地址 http://download.csdn.net/detail/wyyl1/9077749
- android-swipelistview使用说明
- Android SwipeListView用法
- SwipeListView滑动删除Android
- SwipeListView
- SwipeListView
- android-swipelistview项目打包测试
- android库SwipeListView的使用
- android 仿微信侧滑删除SwipeListView实例
- android SwipeListView开源项目导入
- android-swipelistview 导入和d使用
- android SwipeListView开源项目导入
- android--SwipeListView实现ListView滑动删除效果
- android开发之SwipeListView的使用
- 关于android-swipelistview的开源项目的使用
- Android SwipeListView 实现ListView的滑动删除效果
- Android SwipeListView 实现ListView的滑动删除效果
- android开发之开源项目SwipeListView之使用
- Android常用组件——定制化的SwipeListView
- JNI本地接口
- 不论做什么,都应该努力做到最好
- 如何快速梳理一个项目
- 一个二维码实现苹果和安卓两个市场安装包自动分发
- SSH整合报错:failed to lazily initialize a collection of role
- android-swipelistview使用说明
- Android中meta-data的使用
- HDU 4539 【状压DP】
- TestLink 与 Mantis的集成
- C编译预处理宏
- MYSQL的WHERE子句
- Redis命令
- iOS-浅谈runtime运行时机制01-类与对象的内部结构
- Windows内核编程基础篇之系统线程