Back to project page BarcodeTest.
The source code is released under:
Copyright (c) 2014, zhongwcool All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * R...
If you think the Android project BarcodeTest listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.zxing.view; // w ww. ja va 2s .c o m import android.view.View; import android.view.ViewGroup; import android.widget.ListAdapter; import android.widget.ListView; public class Utility { public static void setListViewHeightBasedOnChildren(ListView listView) { //????ListView???Adapter ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int totalHeight = 0; for (int i = 0, len = listAdapter.getCount(); i < len; i++) { //listAdapter.getCount()?????????? View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); //?????View ??? totalHeight += listItem.getMeasuredHeight(); //??????????? } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); //listView.getDividerHeight()?????????????????? //params.height????????ListView?????????? listView.setLayoutParams(params); } }