출처 :     http://stackoverflow.com/questions/12411060/get-listview-height-after-setadapter

 

ListView lv_marca;

    lv_marca
.setAdapter(adapter_marca);

   
int list_height = getListViewHeight(lv_marca);



   
private int getListViewHeight(ListView list) {
         
ListAdapter adapter = list.getAdapter();

         
int listviewHeight = 0;

          list
.measure(MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED),
                      
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));

          listviewHeight
= list.getMeasuredHeight() * adapter.getCount() + (adapter.getCount() * list.getDividerHeight());

         
return listviewHeight;
   
}

+ Recent posts