我想使用html文件,我在部署它时做了它,它不会锻炼(输入html页面需要显示,但它显示当我部署时不可用的网页)!错误消息也不在LOG中!请任何帮助。我在做什么错了?为什么html5功能在我的android应用程序中不起作用?
public class TestActivity extends Activity {
/** Called when the activity is first created. */
WebView webView =null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView =(WebView)findViewById(R.id.web);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
webView.loadUrl("file:///android-assets/www/index.html");
}
}
这里是我的javascript。
function sayhello(){
alert("hi", document.getElementById('name'),value);
}
和HTML文件是在这里
<!DOCTYPE html>
<html>
<head>
<script src="index.js"></script>
</head>
<body>
What is ur name ?
<input id="name" value="">
<button onclick="sayhello()">say hello</button>
</body>
</head>
</html>
和布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/web"
android:text="@string/hello"
/>
</LinearLayout>
“它不会锻炼”那究竟意味着什么?应用程序不启动,应用程序显示空白屏幕,应用程序崩溃,手机爆炸? – zapl
html页面应该出现,但它不会来...为什么和我在哪里做错了? – Bamadeva