Issue
I am Using Web view in my application every thing is working fine for me, but i am having small problem. When Url contains Disclaimers i should not allow web-view should be clickable. But in all other cases web-view should be clickable.
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.contains("Disclaimers")){
view.setClickable(false);
//Here clickable should be fasle.
return true;
}else{
// In this clickable should be true.
view.setClickable(true);
if(!url.contains("/Home.mvc/Trade")){
showProgressLayout();
}
if(url.contains("/Home.mvc/Trade")){
openTradeScreen(url);
}else{
view.loadUrl(url);
}
return true;
}
}
Solution
I know this is an old question, but someone else might also find this answer here useful. Seems to solve things better than setting just clickable to false.
For lazyness' sake I'll copy the solution from that answer here (edited for this scenario, assuming view
is the webview) :)
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
The original answer gives the following explanation too:
Disables all touch events on a WebView because the touch listener is executed before the default touch behavior of the WebView. By returning true the event is consumed and isn't propagated to the WebView.
Using android:clickable="false" does not disable touch events.
Answered By - Attila Orosz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.