gre*_*eve 16 android listview gridview
我正在尝试创建一个ListView,它将包含两种类型的元素:字符串和GridView.
即将两个字符串和一个GridView放在一个ListView中.
布局应如下所示:
有没有办法做到这一点?
到目前为止,我只能在GridView中显示第一个项目,它在ListView中就像一个常规的String元素一样.
代码可以在这里查看:
任何帮助表示赞赏:)
gre*_*eve 51
回答我自己的问题:
基于这个答案,我创建了这个非常有效的类:
public class NonScrollableGridView extends GridView {
public NonScrollableGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Do not use the highest two bits of Integer.MAX_VALUE because they are
// reserved for the MeasureSpec mode
int heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightSpec);
getLayoutParams().height = getMeasuredHeight();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23435 次 |
| 最近记录: |