In order to disable text selection in a WebView we can
use following approaches:
CSS
* {
user-select:
none;
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
}
This approach will not work on all the versions of
Android as the support was not there till late.
Handling LongClick
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView) this.findViewById(R.id.webView1);
webView.loadData("<html><head><style>head><body>You scored <b>192</b> points.</body></html>", "text/html", null);
webView.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
return true;
}
});
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView) this.findViewById(R.id.webView1);
webView.loadData("<html><head><style>head><body>You scored <b>192</b> points.</body></html>", "text/html", null);
webView.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
return true;
}
});
}
Comments
Post a Comment