本文整理匯總了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);
}
示例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);
}
示例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;
}
示例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!");
}
}
}
}
}
示例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();
}
示例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();
}
示例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);
}
示例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!");
}
}
}
}
}
示例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!");
}
}
}
}
}
示例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);
//}
}
}
}
}