本文整理匯總了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);
}
}
}