当前位置: 首页>>代码示例>>Java>>正文


Java ExpandableListAdapter.getGroupView方法代码示例

本文整理汇总了Java中android.widget.ExpandableListAdapter.getGroupView方法的典型用法代码示例。如果您正苦于以下问题:Java ExpandableListAdapter.getGroupView方法的具体用法?Java ExpandableListAdapter.getGroupView怎么用?Java ExpandableListAdapter.getGroupView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ExpandableListAdapter的用法示例。


在下文中一共展示了ExpandableListAdapter.getGroupView方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAdapter

import android.widget.ExpandableListAdapter; //导入方法依赖的package包/类
@Override
public void setAdapter(ExpandableListAdapter adapter) {
    super.setAdapter(adapter);
    mAdapter = adapter;
    mHeaderView = adapter.getGroupView(0, false, null, this);
    boolean isBaseAdapter = adapter instanceof BaseExpandableListAdapter;
    if (cacheHeaderViews == null) {
        if (isBaseAdapter) {
            int typeCount = ((BaseExpandableListAdapter) adapter).getGroupTypeCount();
            cacheHeaderViews = new SparseArray<>(typeCount);
        }
        cacheHeaderViews = new SparseArray<>(1);
    }
    if (mHeaderView != null) {
        int groupType = 0;
        if (isBaseAdapter) {
            groupType = ((BaseExpandableListAdapter) adapter).getGroupType(0);
            cacheHeaderViews.put(groupType, mHeaderView);
        }
        cacheHeaderViews.put(groupType, mHeaderView);
    }
}
 
开发者ID:KobeGong,项目名称:StickyAnimatedExpandableGridView,代码行数:23,代码来源:StickyHeaderExpandableGridView.java

示例2: 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

示例3: onScrollStateChanged

import android.widget.ExpandableListAdapter; //导入方法依赖的package包/类
private void onScrollStateChanged(ExpandableListView elv, int scrollState)
{
	elv.setTag(AQuery.TAG_NUM, scrollState);
	if (scrollState == SCROLL_STATE_IDLE)
	{
		int first = elv.getFirstVisiblePosition();
		int last = elv.getLastVisiblePosition();
		int count = last - first;
		ExpandableListAdapter ela = elv.getExpandableListAdapter();
		for (int i = 0; i <= count; i++)
		{
			long packed = elv.getExpandableListPosition(i + first);
			int group = ExpandableListView.getPackedPositionGroup(packed);
			int child = ExpandableListView.getPackedPositionChild(packed);
			if (group >= 0)
			{
				View convertView = elv.getChildAt(i);
				Long targetPacked = (Long) convertView.getTag(AQuery.TAG_NUM);
				if (targetPacked != null && targetPacked.longValue() == packed)
				{
					if (child == -1)
					{
						ela.getGroupView(group, elv.isGroupExpanded(group), convertView, elv);
					}
					else
					{
						ela.getChildView(group, child, child == ela.getChildrenCount(group) - 1, convertView, elv);
					}
					convertView.setTag(AQuery.TAG_NUM, null);
				}
				else
				{
					//AQUtility.debug("skip!");
				}
			}
		}
	}
}
 
开发者ID:libit,项目名称:lr_dialer,代码行数:39,代码来源:Common.java

示例4: 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

示例5: 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

示例6: reloadGroupViews

import android.widget.ExpandableListAdapter; //导入方法依赖的package包/类
public static void reloadGroupViews(final Context ctx,
                                    final ExpandableListAdapter mAdapter,
                                    final SparseBooleanArray mGroupIdToExpandedMap,
                                    final LinearLayout mLinearLayout,
                                    final int maxNumberOfItemsToshow) {
    if (ctx == null || mLinearLayout == null || mAdapter == null || mGroupIdToExpandedMap == null) {
        return;
    }

    int groupCount = Math.min(mAdapter.getGroupCount(), maxNumberOfItemsToshow);
    if (groupCount == 0) {
        mLinearLayout.removeAllViews();
        return;
    }

    int numExistingGroupViews = mLinearLayout.getChildCount();

    // remove excess views
    if (groupCount < numExistingGroupViews) {
        int numToRemove = numExistingGroupViews - groupCount;
        mLinearLayout.removeViews(groupCount, numToRemove);
        numExistingGroupViews = groupCount;
    }

    int bgColor = Color.TRANSPARENT;

    // add each group
    for (int i = 0; i < groupCount; i++) {
        boolean isExpanded = mGroupIdToExpandedMap.get(i);

        // reuse existing view when possible
        final View groupView;
        if (i < numExistingGroupViews) {
            View convertView = mLinearLayout.getChildAt(i);
            groupView = mAdapter.getGroupView(i, isExpanded, convertView, mLinearLayout);
            groupView.setBackgroundColor(bgColor);
            setViewBackgroundWithoutResettingPadding(groupView, i == 0 ? 0 : R.drawable.stats_list_item_background);
        } else {
            groupView = mAdapter.getGroupView(i, isExpanded, null, mLinearLayout);
            groupView.setBackgroundColor(bgColor);
            setViewBackgroundWithoutResettingPadding(groupView, i == 0 ? 0 : R.drawable.stats_list_item_background);
            mLinearLayout.addView(groupView);
        }

        // groupView is recycled, we need to reset it to the original state.
        ViewGroup childContainer = (ViewGroup) groupView.findViewById(R.id.layout_child_container);
        if (childContainer != null) {
            childContainer.setVisibility(View.GONE);
        }
        // Remove any other prev animations set on the chevron
        final ImageView chevron = (ImageView) groupView.findViewById(R.id.stats_list_cell_chevron);
        if (chevron != null) {
            chevron.clearAnimation();
            chevron.setImageResource(R.drawable.stats_chevron_right);
        }

        // add children if this group is expanded
        if (isExpanded) {
            StatsUIHelper.showChildViews(mAdapter, mLinearLayout, i, groupView, false);
        }

        // toggle expand/collapse when group view is tapped
        final int groupPosition = i;
        groupView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mAdapter.getChildrenCount(groupPosition) == 0) {
                    return;
                }
                boolean shouldExpand = !mGroupIdToExpandedMap.get(groupPosition);
                mGroupIdToExpandedMap.put(groupPosition, shouldExpand);
                if (shouldExpand) {
                    StatsUIHelper.showChildViews(mAdapter, mLinearLayout, groupPosition, groupView, true);
                } else {
                    StatsUIHelper.hideChildViews(groupView, groupPosition, true);
                }
            }
        });
    }
}
 
开发者ID:ldsddn,项目名称:wordpress_app_android,代码行数:81,代码来源:StatsUIHelper.java

示例7: onScrollStateChanged

import android.widget.ExpandableListAdapter; //导入方法依赖的package包/类
private void onScrollStateChanged(ExpandableListView elv, int scrollState){
	
	elv.setTag(AQuery.TAG_NUM, scrollState);
	
	if(scrollState == SCROLL_STATE_IDLE){
		
		int first = elv.getFirstVisiblePosition();
		int last = elv.getLastVisiblePosition();
		
		int count = last - first;
		
		ExpandableListAdapter ela = elv.getExpandableListAdapter();
		
		for(int i = 0; i <= count; i++){
		
			long packed = elv.getExpandableListPosition(i + first);
			
			int group = ExpandableListView.getPackedPositionGroup(packed);
			int child = ExpandableListView.getPackedPositionChild(packed);
			
			if(group >= 0){
				
				View convertView = elv.getChildAt(i);
				Long targetPacked = (Long) convertView.getTag(AQuery.TAG_NUM);
				
				if(targetPacked != null && targetPacked.longValue() == packed){
				
					if(child == -1){
					
						ela.getGroupView(group, elv.isGroupExpanded(group), convertView, elv);
						
					}else{
						
						ela.getChildView(group, child, child == ela.getChildrenCount(group) - 1, convertView, elv);
						
					}
					convertView.setTag(AQuery.TAG_NUM, null);
				}else{
					//AQUtility.debug("skip!");
				}
				
			}
		
			
		}
		
		
		
	}
}
 
开发者ID:bblue000,项目名称:ExoPlayerDemo,代码行数:51,代码来源:Common.java

示例8: onScrollStateChanged

import android.widget.ExpandableListAdapter; //导入方法依赖的package包/类
private void onScrollStateChanged(ExpandableListView elv, int scrollState) {

		elv.setTag(Constants.TAG_NUM, scrollState);

		if (scrollState == SCROLL_STATE_IDLE) {

			int first = elv.getFirstVisiblePosition();
			int last = elv.getLastVisiblePosition();

			int count = last - first;

			ExpandableListAdapter ela = elv.getExpandableListAdapter();

			for (int i = 0; i <= count; i++) {

				long packed = elv.getExpandableListPosition(i + first);

				int group = ExpandableListView.getPackedPositionGroup(packed);
				int child = ExpandableListView.getPackedPositionChild(packed);

				if (group >= 0) {

					View convertView = elv.getChildAt(i);
					Long targetPacked = (Long) convertView
							.getTag(Constants.TAG_NUM);

					if (targetPacked != null
							&& targetPacked.longValue() == packed) {

						if (child == -1) {

							ela.getGroupView(group, elv.isGroupExpanded(group),
									convertView, elv);

						} else {

							ela.getChildView(group, child,
									child == ela.getChildrenCount(group) - 1,
									convertView, elv);

						}
						convertView.setTag(Constants.TAG_NUM, null);
					} else {
						// AQUtility.debug("skip!");
					}

				}

			}

		}
	}
 
开发者ID:steven2947,项目名称:NeXT_pyp,代码行数:53,代码来源:Common.java

示例9: onScrollStateChanged

import android.widget.ExpandableListAdapter; //导入方法依赖的package包/类
private void onScrollStateChanged(ExpandableListView elv, int scrollState){
	
	elv.setTag(AQuery.TAG_NUM, scrollState);
	
	if(scrollState == SCROLL_STATE_IDLE){
		
		int first = elv.getFirstVisiblePosition();
		int last = elv.getLastVisiblePosition();
		
		int count = last - first;
		
		ExpandableListAdapter ela = elv.getExpandableListAdapter();
		
		for(int i = 0; i <= count; i++){
		
			long packed = elv.getExpandableListPosition(i + first);
			
			int group = ExpandableListView.getPackedPositionGroup(packed);
			int child = ExpandableListView.getPackedPositionChild(packed);
			
			if(group >= 0){
				
				View convertView = elv.getChildAt(i);
				//Long targetPacked = (Long) convertView.getTag(AQuery.TAG_NUM);						
				//if(targetPacked != null && targetPacked.longValue() == packed){
				
					if(child == -1){
					
						ela.getGroupView(group, elv.isGroupExpanded(group), convertView, elv);
						
					}else{
						
						ela.getChildView(group, child, child == ela.getChildrenCount(group) - 1, convertView, elv);
						
					}
					//convertView.setTag(AQuery.TAG_NUM, null);
				//}						
			}
		}
	}
}
 
开发者ID:snuk182,项目名称:aceim,代码行数:42,代码来源:AQueryUtils.java


注:本文中的android.widget.ExpandableListAdapter.getGroupView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。