Android左滑删除+上拉加载上拉刷新+全部删除

2017-07-06 10:50:00来源:http://www.jianshu.com/p/93b8656e0197作者:摇尾的鱼人点击


如题先上图(毕竟是新手,GIF还是不会,敬请谅解)



image.png


image.png


image.png


image.png


image.png


image.png
产品原型:

可加载,可单条删除,多条删除


解决方案:

整合上拉加载下拉刷新(PullToRefreshView)+ 左滑删除(RecyclerView+SlidingButtonView)


主要代码:

1.删除代码


/**
* 删除菜单打开信息接收
*/
@Override
public void onMenuIsOpen(View view) {
mMenu = (SlidingButtonView) view;
}
/**
* 滑动或者点击了Item监听
*
* @param slidingButtonView
*/
@Override
public void onDownOrMove(SlidingButtonView slidingButtonView) {
if (menuIsOpen()) {
if (mMenu != slidingButtonView) {
closeMenu();
}
}
}
/**
* 关闭菜单
*/
public void closeMenu() {
mMenu.closeMenu();
mMenu = null;
}
/**
* 判断是否有菜单打开
*/
public Boolean menuIsOpen() {
if (mMenu != null) {
return true;
}
return false;
}
public interface IonSlidingViewClickListener {
void onItemClick(View view, int position);
void onDeleteBtnClick(View view, int position);
}
public interface RadioClickListener {
void onCheckClick(View view, boolean isCheck, int position);
}
public void selectAll() { // 全选
for (int i = 0; i < mList.size(); i++) {
map.put(i, true);
}
notifyDataSetChanged();
}
public void disSelectAll() { // 全不选
for (int i = 0; i < mList.size(); i++) {
map.put(i, false);
}
notifyDataSetChanged();
}
public void switchSelect() { // 反选
for (int i = 0; i < mList.size(); i++) {
boolean select = map.get(i);
map.put(i, !select);
}
notifyDataSetChanged();
}
public void removeData(int position) {
mList.remove(position);
notifyItemRemoved(position);
}
public void removeAllData(List<String> list1) {
mList.removeAll(list1);
notifyDataSetChanged();
}
public static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(outMetrics);
return outMetrics.widthPixels;
}}

思路虽清晰,但是难以表达,忘见谅!
项目地址:http://download.csdn.net/detail/ma_xiaopeng/9889694#




微信扫一扫

第七城市微信公众平台