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


Java BaseExpandableListAdapter.getChildrenCount方法代碼示例

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


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

示例1: getVisibleChildViews

import android.widget.BaseExpandableListAdapter; //導入方法依賴的package包/類
/**
 * Provides the visible child views.
 * The map key is the group position.
 * The map values are the visible child views.
 *
 * @param expandableListView the listview
 * @param adapter            the linked adapter
 * @return visible views map
 */
public static HashMap<Integer, List<Integer>> getVisibleChildViews(ExpandableListView expandableListView, BaseExpandableListAdapter adapter) {
    HashMap<Integer, List<Integer>> map = new HashMap<>();

    long firstPackedPosition = expandableListView.getExpandableListPosition(expandableListView.getFirstVisiblePosition());

    int firstGroupPosition = ExpandableListView.getPackedPositionGroup(firstPackedPosition);
    int firstChildPosition = ExpandableListView.getPackedPositionChild(firstPackedPosition);

    long lastPackedPosition = expandableListView.getExpandableListPosition(expandableListView.getLastVisiblePosition());

    int lastGroupPosition = ExpandableListView.getPackedPositionGroup(lastPackedPosition);
    int lastChildPosition = ExpandableListView.getPackedPositionChild(lastPackedPosition);

    for (int groupPos = firstGroupPosition; groupPos <= lastGroupPosition; groupPos++) {
        ArrayList<Integer> list = new ArrayList<>();

        int startChildPos = (groupPos == firstGroupPosition) ? firstChildPosition : 0;
        int endChildPos = (groupPos == lastGroupPosition) ? lastChildPosition : adapter.getChildrenCount(groupPos) - 1;

        for (int index = startChildPos; index <= endChildPos; index++) {
            list.add(index);
        }

        map.put(groupPos, list);
    }

    return map;
}
 
開發者ID:vector-im,項目名稱:riot-android,代碼行數:38,代碼來源:VectorUtils.java

示例2: populateView

import android.widget.BaseExpandableListAdapter; //導入方法依賴的package包/類
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
    int position = cursor.getPosition();

    // set list title
    TextView title = (TextView) view.findViewById(android.R.id.title);
    if (title != null)
    {
        title.setText(getTitle(cursor, view.getContext()));
    }

    // set list elements
    TextView text2 = (TextView) view.findViewById(android.R.id.text2);
    int childrenCount = adapter.getChildrenCount(position);
    if (text2 != null && ((ExpandableGroupDescriptorAdapter) adapter).childCursorLoaded(position))
    {
        Resources res = view.getContext().getResources();
        text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount));

    }

    // show/hide divider
    View divider = view.findViewById(R.id.divider);
    if (divider != null)
    {
        divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE);
    }

    View colorbar = view.findViewById(R.id.colorbar1);
    if (colorbar != null)
    {
        colorbar.setVisibility(View.GONE);
    }
}
 
開發者ID:dmfs,項目名稱:opentasks,代碼行數:36,代碼來源:ByStartDate.java

示例3: populateView

import android.widget.BaseExpandableListAdapter; //導入方法依賴的package包/類
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
    int position = cursor.getPosition();

    // set list title
    TextView title = (TextView) view.findViewById(android.R.id.title);
    if (title != null)
    {
        title.setText(getTitle(cursor, view.getContext()));
    }

    // set list elements
    TextView text2 = (TextView) view.findViewById(android.R.id.text2);
    int childrenCount = adapter.getChildrenCount(position);
    if (text2 != null && ((ExpandableGroupDescriptorAdapter) adapter).childCursorLoaded(position))
    {
        Resources res = view.getContext().getResources();

        text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount));
    }

    // show/hide divider
    View divider = view.findViewById(R.id.divider);
    if (divider != null)
    {
        divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE);
    }

    View colorbar1 = view.findViewById(R.id.colorbar1);
    View colorbar2 = view.findViewById(R.id.colorbar2);

    if ((flags & FLAG_IS_EXPANDED) != 0)
    {
        if (colorbar1 != null)
        {
            colorbar1.setBackgroundColor(cursor.getInt(2));
            colorbar1.setVisibility(View.GONE);
        }
        if (colorbar2 != null)
        {
            colorbar2.setVisibility(View.GONE);
        }
    }
    else
    {
        if (colorbar1 != null)
        {
            colorbar1.setVisibility(View.GONE);
        }
        if (colorbar2 != null)
        {
            colorbar2.setBackgroundColor(cursor.getInt(2));
            colorbar2.setVisibility(View.GONE);
        }
    }
}
 
開發者ID:dmfs,項目名稱:opentasks,代碼行數:58,代碼來源:ByProgress.java


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