I have a TextView
and ListView
in my activity.ListView
intially set to Visibility = gone
I need a functionality like if u
you can try this function to update the height of listView
public static void updateListViewHeight(ListView myListView) {
ListAdapter myListAdapter = myListView.getAdapter();
if (myListAdapter == null) {
return;
}
// get listview height
int totalHeight = 0;
int adapterCount = myListAdapter.getCount();
for (int size = 0; size < adapterCount; size++) {
View listItem = myListAdapter.getView(size, null, myListView);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
// Change Height of ListView
ViewGroup.LayoutParams params = myListView.getLayoutParams();
params.height = (totalHeight
+ (myListView.getDividerHeight() * (adapterCount));
myListView.setLayoutParams(params);
}