Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void avoidScrollError(ListView listView, TopListAdapter listAdapter){
- if (listAdapter == null) {
- return;
- }
- int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom();
- for (int i = 0; i < listAdapter.getCount(); i++) {
- View listItem = listAdapter.getView(i, null, listView);
- if (listItem instanceof ViewGroup) {
- listItem.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- }
- listItem.measure(0, 0);
- totalHeight += listItem.getMeasuredHeight();
- }
- ViewGroup.LayoutParams params = listView.getLayoutParams();
- params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
- listView.setLayoutParams(params);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement