«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

올해는 머신러닝이다.

listview height 구하는 방법 본문

Android/Tip&Tech

listview height 구하는 방법

행복한 수지아빠 2014. 2. 27. 18:04

출처 :     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;
   
}