1

我按照本教程进行了基于音乐应用播放列表使用的组件的拖放列表视图实现。

http://www.techrepublic.com/blog/australia/making-a-sortable-listview-in-android/708

可拖动列表视图工作正常,但在界面生成器中有错误:

The following classes could not be instantiated:
- com.ib.myproject.TouchInterceptor (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse

这是xml文件的一部分:

<com.ib.myproject.TouchInterceptor
    android:id="@+id/listViewBankList"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:drawSelectorOnTop="false"
    android:fastScrollEnabled="true">
</com.ib.myproject.TouchInterceptor>
4

1 回答 1

2

该错误告诉您界面构建器无法显示任何内容,因为存在无法自行解决的代码逻辑。在您的自定义视图中,您可以使用View.isInEditMode()声明仅由界面构建器调用的代码。

因此,无论是在您的视图中还是包含的活动/片段中,您都可以定义如下内容:

if(View.isInEditMode()) {
  // some code which will help the view instantiate
}
于 2012-10-11T14:16:57.353 回答