dragable列表视图的实现 [英] Implementation of dragable listview

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

问题描述

我跟着这个教程拖放的ListView实现基于这样的音乐应用程序的播放列表中使用的组件。

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

Dragable列表视图工作正常,但在界面生成器出现错误:

 以下类不能被实例化:
 -  com.ib.myproject.TouchInterceptor(公开课,显示错误日志)
查看错误日志(窗口>显示视图)了解更多详情。
提示:使用View.isInEditMode()在你的自定义视图跳过code时,在Eclipse中所示
 

这是XML文件的一部分:

 < com.ib.myproject.TouchInterceptor
    机器人:ID =@ + ID / listViewBankList
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:drawSelectorOnTop =假
    机器人:fastScrollEnabled =真正的>
< /com.ib.myproject.TouchInterceptor>
 

解决方案

这是错误是告诉你的界面生成器不能显示任何东西,因为是它无法自行解决code逻辑。在您的自定义视图,你可以使用 View.isInEditMode()宣布code,将只能通过界面生成器被调用。

所以,无论是在您的视图或含活性/片段,您可以定义的东西,如:

 如果(View.isInEditMode()){
  //一些code,这将有助于该视图实例化
}
 

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

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>

解决方案

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
}

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

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