【发布时间】:2025-12-11 22:35:01
【问题描述】:
我正在用 html5 在 android 中开发一个应用程序。我正在学习在 android studio 上开发应用程序,但我遇到了问题。 “我有一个 index.html”,我可以完美显示,其中有 3 个按钮可以链接到其他 3 个 Html 页面。 当我点击按钮时,应用程序给了我一个错误。 我的活动课如下:
public class MainActivity extends AppCompatActivity {
private WebView wv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wv=(WebView)findViewById(R.id.web);
WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
wv.loadUrl("file:///android_asset/index.html");
}
}
index.html中3个按钮的html代码如下:
<div class="conBtnIntro"><input type="button" value="Addizione" onclick="document.location='summ.html';" id="btn1"class="btnIntro"/></div>
<div class="conBtnIntro"><input type="button" value="Sottrazione" onclick="document.location='diff.html';" id="btn2"class="btnIntro"/></div>
<div class="conBtnIntro"><input type="button" value="Moltiplicazione" onclick="document.location='product.html';" id="btn3"class="btnIntro"/></div>
我哪里错了?
【问题讨论】:
-
When I click on the button the app gives me an error?什么错误? -
应用崩溃
标签: javascript android html url webview