JuHyun Lee
JuHyun Lee

Reputation: 139

Android WebviewClient, Text selection control

enter image description here

  1. Im making a Web app.
    I want block it's selecting texts.
    When I use Facebook application, I can't select text likes the picture's.
    Because facebook app, it's a hybrid app.
    How can I control...
    Is there a any method for blocking text selection??...

  2. When I touch some text which hyper linked,
    Webview showing up orange color border, where around the texts,
    Can I change it color??? or not showing up...??

This is my very simple webviewClient source..

public WebView webViewDefault;
    private Context context = null;
    private String strListsURL = URLOperation.strListsURL;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        this.context = this;

        webViewDefault = (WebView) findViewById(R.id.mainWeb);
        webViewDefault.setVerticalScrollBarEnabled(false);
        webViewDefault.setWebViewClient(new MyClient());
        webViewDefault.loadUrl(strListsURL);


    private class MyClient extends WebViewClient {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageFinished(WebView mWebView, String url) {
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onReceivedError(WebView mWebView, int errorCode, String description, String fallingUrl) {
            mWebView.loadData("<html>Load Error</html>", "text/html", "utf-8");
        }
    }

Upvotes: 0

Views: 1876

Answers (1)

David W
David W

Reputation: 111

In android webview, it enters the text selecting mode by long press the text. you can override the onPerformLongClick() to take over the control and return true to prevent from entering the webtextview mode.

Upvotes: 2

Related Questions