I'm using a webview in my app.
now what I want to do is to pass the data from my javaclass to html.
fro example I have a textview in my android javaclass and when I hit the button send the webview will show with html saying Hi + the name that I input in textview.
is it possible?
Check Using WebViews may be it will help
You can generate your html and then load it to WebView using loadData method for example.
Or you can use addJavascriptInterface to invoke methods of some Java object from javaScript code in WebView
See below code
WebView webview = (WebView) findViewById(R.id.webview);
webview.loadUrl("http://www.xxx.com/web/apps/jots.do");
Related
The error occurred when I used Webview to create a webpage app. The error is "Cannot cast int to android webpage view".
I look forward to it solution
Thank you! in advance
You are missing a findViewById() call
Correct syntax is:
webView = (WebView) findViewById(R.id.webview);
Now in detail, you are trying to cast R.id.webview which actually return int ID value of the view that you have taken in XML layout and then you are trying to cast that directly into the Webview by writing a statement:
webView = (WebView) (R.id.webview)
And there it's showing incovertible types because you are trying to cast integer ID value into WebView. In Android, when you want to find views from XML then need to use findViewById() method.
use webView = findViewById(R.id.webview);
i need to know how to load Survey Form dynamically from my web url and show it in android.
For that you have to use WebView.
in your OnCreate() method use following code
WebView browser = (WebView) findViewById(R.id.webview);
browser.loadUrl("http://www.tutorialspoint.com");
Tutorial for implementing the complete solution : Open URL in WebView.
After times of searching, I could not find the result for this:
My browser application is using webview, I need to use this function: currentwebview.setWebViewClient(). But I do not know how to get the current webview to apply that function.
I mean when I do not have the current webview id, then is there a way to get current webview for using setWebViewClient() ??
Thank you for your help !!
findViewById same as you would any view.
WebView currentWebView = (WebView) findViewById(R.id.my_web_viewId);
I want my app to interact with my HTML page. Using a scheme and intent filter I can catch links but the problem is how to send things back to the browser.
For example if I want to use my JS function I can use a WebView and call loadUrl("javascript:MyJSFunction(..)
Can I do it with out the view part of the WebView?
Add a WebView and set it visibility to View.GONE
Like
WebView webView=new WebView(this);
webView.setVisibility(View.GONE);
then
webView.loadUrl("javascript:MyJSFunction(..)
In my app,I have link http://mymobilece.com/api/api_getexammaterials.php?id=28,
I want to view in webview ,I try with google document viewer its work fine But i need it without google document viewer,How to show it??
you can use the js for google Doc viever
myScript="<html><iframe src='http://docs.google.com/gview?
url='http://mymobilece.com/api/api_getexammaterials.php?
id=28'&embedded='true' style='width:600px; height:500px;'
frameborder='0'></iframe></html>"
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadData(myscript,"text/html", "UTF-8");
you can use myscript as string variable and use this javascript code(please make sure to remove double quite if above code) and load in webview
You can change the url - width- height variables according to your scripting.
Docs.google.com has a document parser , which basically parses MS-Office files , thats why you can view it on google docs. without that you will have to write document parser. Which will parse files and fetch the contents to display on view. In Short it will be not a good idea to do that. :)