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


Java ExpandableListAdapter.getChildView方法代碼示例

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


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

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

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

示例7: showChildViews

import android.widget.ExpandableListAdapter; //導入方法依賴的package包/類
public static void showChildViews(ExpandableListAdapter mAdapter, LinearLayout mLinearLayout,
                                  int groupPosition, View groupView, boolean animate) {
    int childCount = Math.min(mAdapter.getChildrenCount(groupPosition), STATS_CHILD_MAX_ITEMS);
    if (childCount == 0) {
        return;
    }

    final ViewGroup childContainer = (ViewGroup) groupView.findViewById(R.id.layout_child_container);
    if (childContainer == null) {
        return;
    }

    int numExistingViews = childContainer.getChildCount();
    if (childCount < numExistingViews) {
        int numToRemove = numExistingViews - childCount;
        childContainer.removeViews(childCount, numToRemove);
        numExistingViews = childCount;
    }

    for (int i = 0; i < childCount; i++) {
        boolean isLastChild = (i == childCount - 1);
        if (i < numExistingViews) {
            View convertView = childContainer.getChildAt(i);
            mAdapter.getChildView(groupPosition, i, isLastChild, convertView, mLinearLayout);
        } else {
            View childView = mAdapter.getChildView(groupPosition, i, isLastChild, null, mLinearLayout);
            // remove the right/left padding so the child total aligns to left
            childView.setPadding(0,
                    childView.getPaddingTop(),
                    0,
                    isLastChild ? 0 : childView.getPaddingBottom()); // No padding bottom on last child
            setViewBackgroundWithoutResettingPadding(childView, R.drawable.stats_list_item_child_background);
            childContainer.addView(childView);
        }
    }

    if (childContainer.getVisibility() != View.VISIBLE) {
        if (animate) {
            Animation expand = new ScaleAnimation(1.0f, 1.0f, 0.0f, 1.0f);
            expand.setDuration(ANIM_DURATION);
            expand.setInterpolator(getInterpolator());
            childContainer.startAnimation(expand);
        }
        childContainer.setVisibility(View.VISIBLE);
    }

    StatsUIHelper.setGroupChevron(true, groupView, groupPosition, animate);
}
 
開發者ID:ldsddn,項目名稱:wordpress_app_android,代碼行數:49,代碼來源:StatsUIHelper.java

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

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

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