ListView inside ScrollView not Showing all items in the in the Adapter
Ok.. first of all, i know its very much discouraged to not put a listview
in a scrollview, but this time it was out of my hands and i had no choice.
Now going forward, My Listview items are not showing the last few items in
the adapter when it reaches a certain amount. Not treally sure how to
explain it but What i mean is as an example is, items from: Jan 1 - Aug
22, the listview stops at Aug 15, Jan 1 - Aug 17, it stops at Aug 10 Jan 1
- Mar 17, stops at Mar 15 and so on.
Not really sure what the problem is.. i am using a custom Listview like:
public static void setListViewHeight(ListView listview){
ListAdapter listAdapter = listview.getAdapter();
if(listAdapter == null) {
return;
}
int totalHeight = 0;
// int desiredWidth =
MeasureSpec.makeMeasureSpec(listview.getWidth(),
MeasureSpec.AT_MOST);
for(int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listview);
//listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listview.getLayoutParams();
params.height = totalHeight +
(listview.getDividerHeight()*(listAdapter.getCount() - 1)) +
totalHeight;
listview.setLayoutParams(params);
//listview.requestLayout();
}
Anybody have any issue like the Listview not showing all the items?... Any
idea how to solve this?.. Much appreciated in advance.
No comments:
Post a Comment