我有下面的方法...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