做這個功能主要是專案需要:找了很多資料但是效果都不理想,後來就自己研究寫了乙個,拿出來共享給大家,貼上**大家慢慢看看,還是比較容易懂的。
主要**:
package com.zbq.widget;
import android.content.context;
import android.util.attributeset;
import android.view.gesturedetector;
import android.view.motionevent;
import android.view.view;
import android.widget.listview;
public class delslidelistview extends listview implements
gesturedetector.ongesturelistener, view.ontouchlistener
public delslidelistview(context context, attributeset att)
public void setdeletelistioner(ondeletelistioner mondeletelistioner)
public void setsingletapuplistenner(
listviewonsingletapuplistenner thisonsingletapuplistenner)
private int standard_touch_target_size = 0;
private float mlastmotionx;
public boolean deleteview = false;
private scrolllinerlayout mscrolllinerlayout;
private boolean scroll = false;
private int pointtoposition;
private boolean listviewmoving;
private boolean delall = false;
public boolean islongpress = false;
public boolean isdelall()
public void setdelall(boolean delall)
private void init(context mcontext)
public boolean ondown(motionevent e)
mlastmotionx = e.getx();
pointtoposition = this.pointtoposition((int) e.getx(), (int) e.gety());
final int p = pointtoposition - this.getfirstvisibleposition();
if (mscrolllinerlayout != null)
if (deleteview && p != position)
position = p;
scroll = false;
return true;
} islongpress = false;
position = p;
scroll = false;
listviewmoving = false;
return false;
} public boolean onfling(motionevent e1, motionevent e2, float velocityx,
float velocityy)
public void onlongpress(motionevent e)
public boolean onscroll(motionevent e1, motionevent e2, float distancex,
float distancey) else if (scroll)
if (deltax >= 0 && deltax <= standard_touch_target_size)
}} else
if (deltax >= 0 && deltax <= standard_touch_target_size
&& math.abs(distancey) < 5) }}
}} if (scroll)
return false;
} public void onshowpress(motionevent e)
public boolean onsingletapup(motionevent e)
return false;
} public void setscroll(boolean b)
@override
public boolean ontouchevent(motionevent event)
return super.ontouchevent(event);
} @override
public boolean ontouch(view v, motionevent event) else else
scroll = false;
return true;
}/* else if (math.abs(velocityx) > math.abs(velocityy)
&& deltax2 < -80) */
}return mdetector.ontouchevent(event);
} }public void deleteitem()
}}
android 仿微信通知欄
上面是android7.1系統的顯示效果 notificationmanager manager notificationmanager getsystemservice notification service notificationcompat.builder builder new noti...
微信小程式 滑動刪除
vant ui 框架位址 usingcomponents 2 vant裡面的滑動的操作方法直接使用 left width img 內容 button 的大盒子 wrk img img 渲染的 wrk image src wrk name wrk top 標題 name 渲染的標題 爆款背心 wrk ...
Android仿微信聊天介面
專案已經傳到了github 同樣我先說下思路 1.定義訊息型別需要將所有的訊息字段定義出來,那麼需要哪些欄位了 如上圖所示,這裡就不解釋了 3,如何布局?private void setimagelayout final imageview img,string url else img.setla...