我们在app中使用webView控件的时候,为我们提供了更多的方便,同时也是有很多问题需要我们解决的,就如今天这个问题,web view中有输入框,当我双击输入框的时候,就会出现复制剪切等操作的栏,这个很影响用户体验,因此我们需要把它禁掉。
我们需要自定义webView:
public class MyWebView extends WebView {
private long lastTime = 0L;
public MyWebView(Context context) {
super(context);
}
public MyWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
long currentTime = System.currentTimeMillis();
long time = currentTime - lastTime;
if (time < 300) {
lastTime = currentTime;
return true;
} else {
lastTime = currentTime;
}
break;
}
return super.onTouchEvent(event);
}
然后使用我们自定义的webView就可以了:
<MyWebView
android:id="@+id/activity_comment_web"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
1076

被折叠的 条评论
为什么被折叠?



