前提是,如何获取GridView 中总共有多少行呢?
解决方案 »
- 如何修改内存数据
- 请教一个问题,谢谢各位高手帮帮我!~
- 【高分求助】如何循环把10条数据装进DataTable 再全部写进数据库??
- C#中linkbox怎么用?
- 100分紧急求助:寻求SQL语句:如何查询从当前日期开始,往后退12个小时的数据啊?
- 调试工具(DbgView)这个 工具有哪位达人用过,怎么用
- 请教学习
- 怎么得到datagridviewcomboboxcell中选择内容的index值????
- C#程序员考MCSD的哪个科目比较好呢?
- (急救﹗)WinForm中DataGrid 中的keydown事件如何重寫?
- 请教C#,如何让DataGridView根据数据“0”或“1”等值显示为“男”或“女”
- winform中使用webbrowser遇到cookie问题了
protected void onAttachedToWindow() {
super.onAttachedToWindow();
measureHeight();
}private void measureHeight(){
int childHeight = 0;
mItemCount = getAdapter() == null ? 0 : getAdapter().getCount();
final int count = mItemCount;
if (count > 0) {
final View child = getAdapter().getView(0, null, null);
AbsListView.LayoutParams p = (AbsListView.LayoutParams)child.getLayoutParams();
if (p == null) {
p = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, 0);
child.setLayoutParams(p);
}
int childHeightSpec = getChildMeasureSpec(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 0, p.height);
int childWidthSpec = getChildMeasureSpec(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 0, p.width);
child.measure(childWidthSpec, childHeightSpec);
childHeight = child.getMeasuredHeight();
}
int ourSize = 0;
for (int i = 0; i < count; i += mNumColumns) {
ourSize += childHeight;
}
int heightSize = ourSize;
android.view.ViewGroup.LayoutParams params = getLayoutParams();
params.height = heightSize;
setLayoutParams(params);
}