定义了一个类
public class AppsDragDemo extends GridView
然后在一个layout xml使用这个类
<?xml version="1.0" encoding="utf-8"?>
<com.access.thumbhome.DragLayer
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/drag_layer">
<!-- All applications on the top side of the screen -->
<com.access.thumbhome.AppsDragDemo
android:id="@+id/appsgrid_fordrag"
android:tag="all_apps_fordrag"
android:background="@drawable/application_background"
android:persistentDrawingCache="animation|scrolling"
android:alwaysDrawnWithCache="true" android:scrollbars="none"
android:drawSelectorOnTop="false" android:listSelector="@drawable/grid_selector"
android:numColumns="auto_fit" android:columnWidth="60dp"
android:stretchMode="spacingWidth" android:layout_weight="1.0"
android:layout_height="match_parent" android:layout_width="match_parent"
android:stackFromBottom="false" android:visibility="visible" />
</com.access.thumbhome.DragLayer>
发现使用这个类生成的GridView无法显示数据。花了很长时间也没有找到问题,后来瞥见一段代码
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
}
不知道什么时候重载了这个函数,而这个函数什么都不干,也就是这个空函数把父类的关键方法给替换了,所以,这个GridView没法显示数据。加上下面的一行可以解决问题,或者把这个重载函数删除,反正是没有用的。
super.onLayout(changed, l, t, r, b);