This code is work but the issue is in ListView each item of ListView is diff so last item of ListView is not display because big height ListView item get this space .
here is code:
public static void setListViewHeightBasedOnChildren(ListView listView,DownloadAdapter adapter,LinearLayout layDownloads) {
ListAdapter mAdapter = adapter;
int totalHeight = 0,h=0;
int listWidth=listView.getMeasuredWidth();
for (int i = 0; i < mAdapter.getCount(); i++) {
View mView = mAdapter.getView(i, null, listView);
mView.measure(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
h=mView.getMeasuredHeight();
totalHeight += mView.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight
+ (listView.getDividerHeight() * (mAdapter.getCount() - 1))+h;
listView.setLayoutParams(params);
listView.requestLayout();
}
Here is screen
please help me how to get height of listview of each cell and to to calculate heght of listview? Thanks in advance..
0 comments:
Post a Comment