【问题标题】:Implementation of draggable listview可拖动列表视图的实现
【发布时间】:2012-10-09 09:12:39
【问题描述】:

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

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>

【问题讨论】:

    标签: android xml listview drag-and-drop


    【解决方案1】:

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

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

    if(View.isInEditMode()) {
      // some code which will help the view instantiate
    }
    

    【讨论】:

    • 我应该声明哪些变量?
    • 我应该在使用该无法识别视图的 Activity 中编写 View.isInEditMode() 吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-02
    • 1970-01-01
    • 1970-01-01
    • 2014-09-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多