0
我写了一个扩展了FrameLayout的类。新类扩展FrameLayout无法实例化
public class ReaderFrameLayout extends FrameLayout
{
public ReaderFrameLayout(Context context)
{
this(context, null);
}
public ReaderFrameLayout(Context context, AttributeSet attrs)
{
this(context, attrs, 0);
}
public ReaderFrameLayout(Context context, AttributeSet attrs, int defaultStyle)
{
super(context, attrs, defaultStyle);
WebView readerWebView = (WebView) findViewById(R.id.fragment_reader_webview);
readerWebView.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
Log.d("ReaderFrameLayout", "setOnTouchListener");
return true;
}
});
}
}
并将其添加到片段中。
<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" >
<com.mbs.helpers.ReaderFrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="83dp" >
<WebView
android:id="@+id/fragment_reader_webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</com.mbs.helpers.ReaderFrameLayout>
</RelativeLayout>
在Eclipse中的错误:
com.android.layoutlib.bridge.MockView不能转换到android.view.ViewGroup 异常详细信息记录在窗口>显示视图>错误日志 的以下类无法实例化: - com.mbs.helpers.ReaderFrameLayout(Open Class,Show Error Log) 有关更多详细信息,请参见错误日志(窗口>显示视图)。 提示:在自定义视图中使用View.isInEditMode()可以在Eclipse中显示时跳过代码
当然,该应用程序不起作用。
我在做什么错?
你指的是关系到图形布局Eclipse的错误。这与设备上的操作无关。那么解释一下什么是行不通的?它会抛出错误吗?我看到的只是两个布局,没有别的,如果你设置上面的布局,它将是空的 – nandeesh