【发布时间】:2010-08-09 14:59:16
【问题描述】:
我有以下方法...
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 引用...
<?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 编译错误,但 full 被定义为.. WebView full = (WebView)findViewById(R.id.webview); 有人知道为什么这不起作用吗?
谢谢。
【问题讨论】:
-
是在“onCreate”中吗?如果它找不到它,那么你在错误的“上下文”中。您可以发布该方法的完整代码吗?比如设置内容视图的位置等。
-
ZOOM_PARAMS 变量指的是什么?