Skip to content

Commit 0637019

Browse files
author
ZIP
committed
update demo
1 parent 2663a71 commit 0637019

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@
4343
</script>
4444

4545
### notice :
46-
#### You can do anything with Javascript Interface when button in function `showToast()` of class `WebInterFace` in the top of this README
46+
#### You can do anything with Javascript Interface when `button clicked` in function `showToast()` of class `WebInterFace` in the top of this README
47+
48+
49+
Demo https://youtu.be/3wHA3dh8k-g

app/src/main/assets/a.html

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<title>just tesst</title>
67
<script>
7-
function myFunction() {
8-
document.getElementById("huu").innerHTML = "New from asstes folder tee23xt2!";
9-
document.getElementById("huu").style.color = "green";
10-
11-
12-
}
13-
function myFunction2() {
14-
document.getElementById("huu2").innerHTML = "New text3!z2";
15-
alert("Hello! I am an alert box!!");
8+
function myFunction() {
9+
document.getElementById("huu").innerHTML = "New from asstes folder tee23xt2!";
10+
document.getElementById("huu").style.color = "green";
1611

1712

18-
}
19-
function androiToast() {
20-
toaskAction.showToast();
21-
22-
}
13+
}
2314

15+
function myFunction2() {
16+
document.getElementById("huu2").innerHTML = "New text3!z2";
17+
alert("Hello! I am an alert box!!");
2418

2519

20+
}
2621

22+
function androiToast() {
23+
toaskAction.showToast();
2724

25+
}
2826

27+
function kaka() {
28+
toaskAction.kaka();
29+
}
2930

3031
</script>
3132
</head>
33+
3234
<body>
3335
<button onclick="myFunction()">Copy Text</button>
3436
<button onclick="myFunction2()">Copy Text</button>
3537
<button onclick="androiToast()">Android Toast</button>
36-
37-
38+
<button onclick="kaka()">kaka</button>
3839
<h1 id="huu">a</h1>
3940
<h1 id="huu2">a</h1>
40-
41-
4241
</body>
43-
</html>
42+
43+
</html>

app/src/main/java/com/yokara/javascriptcalljava/MainActivity.java

+5
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,10 @@ public void showToast() {
8787
progressDialog.setTitle("javascript");
8888
progressDialog.show();
8989
}
90+
91+
@JavascriptInterface
92+
public void kaka(){
93+
Toast.makeText(MainActivity.this, "hehe button", Toast.LENGTH_SHORT).show();
94+
}
9095
}
9196
}

0 commit comments

Comments
 (0)