本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
}