【发布时间】:2011-06-11 11:48:46
【问题描述】:
我正在尝试实施找到的解决方案之一here.
我的问题是我不确定我是否正确地实现和使用了我的子类。 我在这里对 WebView 进行子类化:
public class myWebView extends WebView{
public myWebView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
protected void onSizeChanged(int w, int h, int ow, int oh) {
// TODO Auto-generated method stub
scrollTo(xScroll - (widthScroll/2), yScroll - (heightScroll/2));
super.onSizeChanged(w, h, ow, oh);
}
}}
它应该是私有的,但暂时忘记这一点。我的一个活动中有代码,该代码在视图层次结构中有一个内部 web 视图。在该活动的 onCreate 方法之外。
在onCreate方法里面,我有:myWebView mapImage = (myWebView) findViewById(R.id.mapcroppic);
这给了我该调用的 ClassCastException。 (xml布局文件是否需要使用<myWebView>?可以吗?)我该如何正确使用?
【问题讨论】:
标签: android webview android-layout subclassing