首页 > 其他 > 详细

listview嵌套gridview

时间:2016-05-23 10:41:57      阅读:146      评论:0      收藏:0      [点我收藏+]

1.首先要自定义一个继承gridview的类

public class MyGridView extends GridView {
    public boolean hasScrollBar = true;
    public MyGridView(Context context) {
        super(context);
    }

    public MyGridView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
    }
}

2.在布局中引用这个自定义gridview

com.example.administrator.tunrb.MyFragment.Single_fragment.MyGridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/single_gridview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnWidth="80dp"
    android:background="#ffffff"
    android:horizontalSpacing="5dp"
    android:numColumns="auto_fit"
    android:verticalSpacing="5dp"></com.example.administrator.tunrb.MyFragment.Single_fragment.MyGridView>

 

listview嵌套gridview

原文:http://www.cnblogs.com/anni-qianqian/p/5518904.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!