我有下面的方法...Webview不工作?
public class Image extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
/* Using WebView to display the full-screen image */
WebView full = (WebView)findViewById(R.id.webview);
/* Set up the Zoom controls */
FrameLayout mContentView = (FrameLayout) getWindow().
getDecorView().findViewById(android.R.id.content);
final View zoom = this.full.getZoomControls();
mContentView.addView(zoom, ZOOM_PARAMS);
zoom.setVisibility(View.VISIBLE);
/* Create a new Html that contains the full-screen image */
String html = new String();
html = ("<html><center><img src=\"1276253554007.jpg\"></html>");
/* Finally, display the content using WebView */
full.loadDataWithBaseURL("file:///sdcard/DCIM/Camera/",
html,
"text/html",
"utf-8",
"");
}
}
R.id.webview refrences ...
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
但我发现了一个full cannot be resolved or is not a field
编译错误,但全被定义为.. WebView full = (WebView)findViewById(R.id.webview);
任何人都知道为什么这不工作?
谢谢。
是在“onCreate”?如果它无法找到它,那么你是在错误的“背景”。你可以发布整个代码的方法?比如设置内容视图的位置等。 – 2010-08-09 15:03:51
我提出了完整的方法。 – Skizit 2010-08-09 15:13:36
要什么ZOOM_PARAMS变量引用? – 2010-08-09 15:36:53