我的网页视频代码出错。想要创建一个适用于所有Android操作系统的webview。我在正确的道路上吗?
webview1似乎给了我麻烦。不确定为什么。任何指针将不胜感激。提前谢谢。main.java
package com.webapp.Area;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url = "http://www.area.com;";
WebView view = (WebView) this.findViewById(R.id.webview1);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl(url);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true" />
</RelativeLayout>
答案 0 :(得分:0)
:)只需更改以下行。
WebView view = (WebView) this.findViewById(R.id.webview1);
to
WebView view = (WebView) this.findViewById(R.id.webView1); // "V" should be in capital