gridview里面的listview layoutparams android

时间:2013-04-25 10:02:57

标签: android listview gridview layoutparams

使用:

public View getView(int position, View convertView, ViewGroup parent) {
final int type = getItemViewType(position);

if(position == 1){
    GridView gridView = new GridView(context);
    gridView.setNumColumns(3);
    AbsListView.LayoutParams params = new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
    gridView.setLayoutParams(params);
    ArrayAdapter<String>  adapter = new ArrayAdapter<String>(context, R.layout.item, R.id.tvText, new String[]{"as","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah","ah"});
    gridView.setAdapter(adapter);
    return gridView;
}

但是gridview没有完整显示。为什么呢?

截图:
enter image description here

我应该这样:
enter image description here

item.xml

0 个答案:

没有答案