當前位置: 首頁>>代碼示例>>Java>>正文


Java ListView.getPaddingTop方法代碼示例

本文整理匯總了Java中android.widget.ListView.getPaddingTop方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.getPaddingTop方法的具體用法?Java ListView.getPaddingTop怎麽用?Java ListView.getPaddingTop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ListView的用法示例。


在下文中一共展示了ListView.getPaddingTop方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setAdapterHeight

import android.widget.ListView; //導入方法依賴的package包/類
public static void setAdapterHeight(ListView listView){

        android.widget.ListAdapter listAdapter = listView.getAdapter();//1、獲取adapter
        if (listAdapter == null) {
            return;
        }

        int totalHeight = 0;
        for (int i = 0,j =listAdapter.getCount(); i < j ; i++) {  //2、算出沒一個item高度總和
            View listItem = listAdapter.getView(i , null, listView);
            listItem.measure(0, 0);
            totalHeight += listItem.getMeasuredHeight();
        }

        ViewGroup.LayoutParams params=listView.getLayoutParams();
        params.height = totalHeight + listView.getPaddingBottom()   //3、加上listview自身每行間距屬性
                + listView.getPaddingTop()
                + (listView.getDividerHeight() * (listAdapter.getCount() - 1));


        listView.setLayoutParams(params);//4、重新設置高
    }
 
開發者ID:aiyangtianci,項目名稱:BluetoothAPP,代碼行數:23,代碼來源:ListViewHeightMesure.java

示例2: canListViewScrollUp

import android.widget.ListView; //導入方法依賴的package包/類
/**
 * Utility method to check whether a {@link ListView} can scroll up from it's current position.
 * Handles platform version differences, providing backwards compatible functionality where
 * needed.
 */
private static boolean canListViewScrollUp(ListView listView) {
    if (android.os.Build.VERSION.SDK_INT >= 14) {
        // For ICS and above we can call canScrollVertically() to determine this
        return ViewCompat.canScrollVertically(listView, -1);
    } else {
        // Pre-ICS we need to manually check the first visible item and the child view's top
        // value
        return listView.getChildCount() > 0 &&
                (listView.getFirstVisiblePosition() > 0
                        || listView.getChildAt(0).getTop() < listView.getPaddingTop());
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:SwipeRefreshListFragment.java

示例3: setListViewHeightBasedOnItems

import android.widget.ListView; //導入方法依賴的package包/類
public static boolean setListViewHeightBasedOnItems(ListView listView) {

        ListAdapter listAdapter = listView.getAdapter();
        if (listAdapter != null) {

            int numberOfItems = listAdapter.getCount();

            // Get total height of all items.
            int totalItemsHeight = 0;
            for (int itemPos = 0; itemPos < numberOfItems; itemPos++) {
                View item = listAdapter.getView(itemPos, null, listView);
                item.measure(0, 0);
                totalItemsHeight += item.getMeasuredHeight();
            }

            // Get total height of all item dividers.
            int totalDividersHeight = listView.getDividerHeight() *
                    (numberOfItems - 1);

            int topPAdding = listView.getPaddingTop();
            int bottomPadding = listView.getPaddingBottom();

            // Set list height.
            ViewGroup.LayoutParams params = listView.getLayoutParams();
            params.height = totalItemsHeight + totalDividersHeight + topPAdding + bottomPadding;
            listView.setLayoutParams(params);
            listView.requestLayout();

            return true;

        } else {
            return false;
        }

    }
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:36,代碼來源:ViewUtil.java

示例4: setHeightofListViewBasedOnContent

import android.widget.ListView; //導入方法依賴的package包/類
public void setHeightofListViewBasedOnContent(ListView listView) {

        ListAdapter mAdapter = listView.getAdapter();

        int totalHeight = 0;

        for (int i = 0; i < mAdapter.getCount(); i++) {

            totalHeight += getResources().getDimension(R.dimen.item_list_height);
            Log.w("HEIGHT" + i, String.valueOf(totalHeight));

        }

        totalHeight = totalHeight +  (listView.getDividerHeight() * (mAdapter.getCount() - 1)) + listView.getPaddingTop();

        ViewGroup.LayoutParams params = listView.getLayoutParams();
        params.height = totalHeight;
        listView.setLayoutParams(params);
        listView.requestLayout();

    }
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:22,代碼來源:ArtistDetailActivity.java


注:本文中的android.widget.ListView.getPaddingTop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。