Created
January 23, 2015 15:14
-
-
Save AlexHedley/8b015912875c8f1e693e to your computer and use it in GitHub Desktop.
Android WebView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Button button = (Button) findViewById(R.id.button); | |
| Toolbar toolbar = (Toolbar) findViewById(R.id.myToolbar); | |
| final WebView webView = (WebView) findViewById(R.id.webView); | |
| //Set links to show in webview not open in another program. | |
| webView.setWebViewClient(new WebViewClient()); | |
| webView.getSettings().setJavaScriptEnabled(true); | |
| String url = "http://www.alexhedley.com/form.asp"; | |
| webView.loadUrl(url); | |
| View.OnClickListener listener = new View.OnClickListener() { | |
| @Override | |
| public void onClick(View v) { | |
| String barcode = "barcode"; | |
| String fillIn = "document.getElementById('barcode').value = '" + barcode + "';"; | |
| String click = "(function(){document.getElementById('btnEnter').click();})()"; | |
| String combined = "javascript:" + fillIn + click; | |
| webView.loadUrl(combined); | |
| } | |
| }; | |
| button.setOnClickListener(listener); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <android.support.v7.widget.Toolbar | |
| android:id="@+id/myToolbar" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentBottom="true" | |
| /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <form method="POST" action="form-process.asp"> | |
| <label for="barcode">Barcode: </label> | |
| <input id="barcode" name="barcode" type="text" value=""> | |
| <br /> | |
| <input id="btnEnter" name="btnEnter" type="submit" value="Submit"> | |
| </form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <uses-permission | |
| android:name="android.permission.INTERNET"> | |
| </uses-permission> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment