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


Java ExpandableListAdapter.getChildrenCount方法代碼示例

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


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

示例1: setExpandedListViewHeightBasedOnChildren

import android.widget.ExpandableListAdapter; //導入方法依賴的package包/類
public static void setExpandedListViewHeightBasedOnChildren(ExpandableListView listView, int groupPosition) {
    ExpandableListAdapter listAdapter = listView.getExpandableListAdapter();
    if (listAdapter == null) {
        return;
    }
    View listItem = listAdapter.getChildView(groupPosition, 0, true, null,
            listView);
    listItem.measure(0, 0);
    int appendHeight = 0;
    for (int i = 0; i < listAdapter.getChildrenCount(groupPosition); i++) {
        appendHeight += listItem.getMeasuredHeight();
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height += appendHeight;
    listView.setLayoutParams(params);
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:17,代碼來源:ExpandedListUtils.java

示例2: setCollapseListViewHeightBasedOnChildren

import android.widget.ExpandableListAdapter; //導入方法依賴的package包/類
public static void setCollapseListViewHeightBasedOnChildren(ExpandableListView listView, int groupPosition) {
    ExpandableListAdapter listAdapter = listView.getExpandableListAdapter();
    if (listAdapter == null) {
        return;
    }
    View listItem = listAdapter.getChildView(groupPosition, 0, true, null,
            listView);
    listItem.measure(0, 0);
    int appendHeight = 0;
    for (int i = 0; i < listAdapter.getChildrenCount(groupPosition); i++) {
        appendHeight += listItem.getMeasuredHeight();
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height -= appendHeight;
    listView.setLayoutParams(params);
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:17,代碼來源:ExpandedListUtils.java

示例3: setListViewHeightBasedOnItems

import android.widget.ExpandableListAdapter; //導入方法依賴的package包/類
/**
 * Sets ExpandableListView height dynamically based on the height of the items.
 *
 * @param expandablelistView to be resized
 * @return true if the expandablelistView is successfully resized, false otherwise
 */
public static boolean setListViewHeightBasedOnItems(ExpandableListView expandablelistView) {

    ExpandableListAdapter expandableListAdapter = expandablelistView.getExpandableListAdapter();
    if (expandableListAdapter != null) {

        int numberOfGroups = expandableListAdapter.getGroupCount();
        int numberOfDividers = numberOfGroups;

        // Get total height of all items of all group expanded
        int totalItemsHeight = 0;

        for (int groupPos = 0; groupPos < numberOfGroups; groupPos++) {

            View item = expandableListAdapter.getGroupView(groupPos, expandablelistView.isGroupExpanded(groupPos), null, expandablelistView);
            item.measure(0, 0);
            totalItemsHeight += item.getMeasuredHeight();

            if(expandablelistView.isGroupExpanded(groupPos)) {
                totalItemsHeight += calculateHeightOfOneGroup(groupPos, expandableListAdapter, expandablelistView);
                numberOfDividers += expandableListAdapter.getChildrenCount(groupPos);
            }
        }

        // Get total height of all item dividers.
        int totalDividersHeight = expandablelistView.getDividerHeight() * numberOfDividers;

        // Set list height.
        ViewGroup.LayoutParams params = expandablelistView.getLayoutParams();
        params.height = totalItemsHeight + totalDividersHeight + 5;
        expandablelistView.setLayoutParams(params);
        expandablelistView.requestLayout();

        return true;
    } else {
        return false;
    }
}
 
開發者ID:Orange-OpenSource,項目名稱:m-dan,代碼行數:44,代碼來源:Utils.java

示例4: calculateHeightOfOneGroup

import android.widget.ExpandableListAdapter; //導入方法依賴的package包/類
/**
 * Calculate the height of an expanded group dynamically based on the height of the items.
 *
 * @param groupPos position of the current group
 * @param expandableListAdapter adapter of the expandableList
 * @param parent the parent that this view will eventually be attached to
 * @return true if the listView is successfully resized, false otherwise
 */
public static int calculateHeightOfOneGroup(int groupPos, ExpandableListAdapter expandableListAdapter, ViewGroup parent) {

    int numberOfItems = expandableListAdapter.getChildrenCount(groupPos);

    // Get total height of all items in the group
    int totalItemsHeight = 0;

    for (int itemPos = 0; itemPos < numberOfItems; itemPos++) {

        boolean lastItem = false;
        if(itemPos == numberOfItems-1){
            lastItem = true;
        }

        // Supprimer le if si on veut garder un truc générique. Ici, le if sert à gérer la cutom expandable en plus des expandables classiques
        View item;
        if(expandableListAdapter instanceof com.orange.ease.idunnololz.widgets.AnimatedExpandableListView.AnimatedExpandableListAdapter){
            item = ((AnimatedExpandableListView.AnimatedExpandableListAdapter) expandableListAdapter).getRealChildView(groupPos, itemPos, lastItem, null, parent);
        }else{
            item = expandableListAdapter.getChildView(groupPos, itemPos, lastItem, null, parent);
        }


        item.measure(0, 0);
        totalItemsHeight += item.getMeasuredHeight();
    }

    return totalItemsHeight;
}
 
開發者ID:Orange-OpenSource,項目名稱:m-dan,代碼行數:38,代碼來源:Utils.java

示例5: updateExpandableListViewHeight

import android.widget.ExpandableListAdapter; //導入方法依賴的package包/類
/**
 * To compute the expandable listview for a given group.
 *
 * @param listView ExpandableListView
 * @param group    group
 */
public static void updateExpandableListViewHeight(ExpandableListView listView,
                                                  int group) {
    ExpandableListAdapter listAdapter = (ExpandableListAdapter) listView.getExpandableListAdapter();
    if (listAdapter == null) {
        // pre-condition
        return;
    }

    int totalHeight = 0;
    for (int i = 0; i < listAdapter.getGroupCount(); i++) {
        View groupItem = listAdapter.getGroupView(i, false, null, listView);
        groupItem.measure(0, 0);

        totalHeight += groupItem.getMeasuredHeight();

        if (((listView.isGroupExpanded(i)) && (i != group))
                || ((!listView.isGroupExpanded(i)) && (i == group))) {
            for (int j = 0; j < listAdapter.getChildrenCount(i); j++) {
                View listItem = listAdapter.getChildView(i, j, false, null, listView);
                listItem.measure(0, 0);
                totalHeight += listItem.getMeasuredHeight();
            }
        }
    }

    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getGroupCount() - 1));
    listView.setLayoutParams(params);
    listView.requestLayout();
}
 
開發者ID:Orange-OpenSource,項目名稱:ocara,代碼行數:37,代碼來源:ListViewUtils.java

示例6: setListViewHeight

import android.widget.ExpandableListAdapter; //導入方法依賴的package包/類
public static void setListViewHeight(ExpandableListView listView, int group) {
    ExpandableListAdapter listAdapter = listView.getExpandableListAdapter();
    int totalHeight = 0;
    int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(),
            MeasureSpec.AT_MOST);
    for (int i = 0; i < listAdapter.getGroupCount(); i++) {
        View groupItem = listAdapter.getGroupView(i, false, null, listView);
        groupItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);

        totalHeight += groupItem.getMeasuredHeight();

        if (((listView.isGroupExpanded(i)) && (i != group))
                || ((!listView.isGroupExpanded(i)) && (i == group))) {
            for (int j = 0; j < listAdapter.getChildrenCount(i); j++) {
                View listItem = listAdapter.getChildView(i, j, false, null,
                        listView);
                listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);

                totalHeight += listItem.getMeasuredHeight();

            }
        }
    }

    ViewGroup.LayoutParams params = listView.getLayoutParams();
    int height = totalHeight
            + (listView.getDividerHeight() * (listAdapter.getGroupCount() - 1));
    if (height < 10)
        height = 200;
    params.height = height;
    listView.setLayoutParams(params);
    listView.requestLayout();
}
 
開發者ID:orelzion,項目名稱:tehilim,代碼行數:34,代碼來源:Tools.java


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