i have a hybrid app. I used web-view to make a android hybrid app. I also have a native menubar above the webview. My question is, How can i disable the native menu from my web application? Is it possible? If yes please share your thoughts on this
3 Answers
Check the answer of this question, as they provide snippet code to call Java method from javascript in Android, this will help you if you create a Java method that will disable your ImageButton from a Javascript
5 Comments
JustCode
Since there is limitation, I cant change any code from native side. I want to do it only through my web application using javascript.
Amine ABDALKHALKI
What limitation? do you have the access to the ImageView in your native code? if so you can disable it. if you don't have the Id of the imageView so there is no way possible for change it's state
JustCode
Amine ABDALKHALKI - i cant change any code in native but i know the id of ImageButton. All i want is without changing any code in native, i want to disable the Imagebutton from my javascript
Amine ABDALKHALKI
from Javascript you can't change a "thing" without calling a native code.. i hope it's clear for you
JustCode
ohhh :( thank you for responding :) Amine ABDALKHALKI
You will need to find the user-agent click here to see how to check useragent then u can write a simple javascript function on page load to disable your header
Comments
Try to set webviewclient to your webview and override onPageFinished like this. In my project I tried to hide google and facebook buttons on fitbit page.
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if (!TextUtils.isEmpty(url) && url.contains("fitbit")) {
view.loadUrl("javascript: setTimeout(function () { $('.external-choices,.or').hide();} , 1000) ");//JS to hide the fitbit login from G+ and FB
}
}
}
2 Comments
JustCode
Since there is limitation, I cant change any code from native side. I want to do it only through my web application using javascript.
Ravi
Could you please post screenshot, if you are trying to hide action bar can't you set the theme of that activity which holds your webview accordingly