可拖动列表视图的实现 [英] Implementation of draggable listview

查看:73
本文介绍了可拖动列表视图的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I followed this tutorial for drag and drop listview implementation based on component that the Music app’s playlist uses.

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

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

Dragable listview works fine, but in the interface builder there is the error:

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文件的一部分:

Here it is the part of the xml file:

<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>

推荐答案

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

That error is telling you that the interface builder can't display anything as there is code logic which it can't resolve by itself. In your custom view you can use View.isInEditMode() to declare code which will only be called by the interface builder.

因此,在您的视图或包含活动/片段的区域中,您都可以定义以下内容:

So either in your view or the containing activity/fragment, you can define something such as:

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

这篇关于可拖动列表视图的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆