D
D
DragoN DragoN2018-05-02 14:23:45
Android
DragoN DragoN, 2018-05-02 14:23:45

How to handle click on specific html text?

There is html text in which there are tags with special attributes, with special styles, by clicking on them, you need to perform an action in the application without leaving the activity.
Is there such a possibility and how to implement it?
Perhaps you know another approach, something like parsing the text and inserting it into the required position of the button

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-05-02
@DrDragoN

Yes - you need to tell your WebView that you decide what to do with links.

WebView webView;//должен уже быть прогружен виджет и задан обработчик 
webView.setWebViewClient(webViewClient);//устанавливаем обработчик
//сам обработчик - куда нить в инит активити
WebViewClient webViewClient= new WebViewClient(){
    @Override
    public boolean shouldOverrideUrlLoading(WebView  view, String  url){
        return true;
    }
    @Override
    public void onLoadResource(WebView  view, String  url){
        if( url.equals("http://адрес-сайта.рф") ){
            // тут чего нибудь выполнить
        }
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question