How to load new Activity onclick <button>?
How to change Activity , load new Activity, when I click on inside HTML page which I shows inside WebView. Demo.html is in assets. How to load new Activity ? This is Demo.html inside assets
<html>
<script开发者_运维百科 language="javascript">
/* This function is invoked by the activity */
function wave() {
alert("1");
//What to do to change on new Activity
alert("2");
}
</script>
<body>
<!-- Calls into the javascript interface for the activity -->
<a onClick="window.demo.clickOnAndroid()">
<div style="width:80px;
margin:0px auto;
padding:10px;
text-align:center;
border:2px solid #202020;" >
<input id="test" type="button" onclick="wave">Click Me!</button>
</div></a>
</body>
</html>
What to do so when I click on button with id="test" I go to new activity in android app, like I do in normal way when use Button in android, not in JavaScript
Intent i = new Intent(getApplicationContext(), Test.class);
startActivity(i);
If I have understand correct (meaning start a new Activity when clicking on the button) you should check here for a complete guide: http://developer.android.com/guide/webapps/webview.html and more specifically the section 'Binding JavaScript code to Android code'. Try this and if you have any problem come back again. Hope this helps!
Have a look at this.What WebView can do in Android ?. This blog shows how to call an android activity or method via javascript.
精彩评论