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