Methods Summary |
---|
protected android.widget.ExpandableListAdapter | createAdapter()
return new MyAdapter();
|
protected android.widget.ListView | createListView()
return new ExpandableListView(this);
|
protected Params | createParams()
return new ExpandableParams();
|
protected android.view.View | createView(long packedPosition, int flPos, android.view.ViewGroup parent, int desiredHeight)Create a view for a group or child position.
TextView result = new TextView(parent.getContext());
result.setHeight(desiredHeight);
result.setText(getValueAtPosition(packedPosition));
final ViewGroup.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
result.setLayoutParams(lp);
result.setGravity(Gravity.CENTER_VERTICAL);
result.setPadding(36, 0, 0, 0);
result.setId(flPos);
return result;
|
public int | findGroupWithNumChildren(int numChildren, boolean atLeastOneChild)Returns a group index containing either the number of children or at
least one child.
final ExpandableListAdapter adapter = mAdapter;
for (int i = adapter.getGroupCount() - 1; i >= 0; i--) {
final int curNumChildren = adapter.getChildrenCount(i);
if (numChildren == curNumChildren || atLeastOneChild && curNumChildren > 0) {
return i;
}
}
return -1;
|
public android.widget.ExpandableListAdapter | getAdapter()
return mAdapter;
|
public android.widget.ExpandableListView | getExpandableListView()Get the ExpandableListView widget.
return (ExpandableListView) super.getListView();
|
public java.util.List | getGroups()
return mGroups;
|
public final java.lang.String | getValueAtPosition(long packedPosition)Gets a string for the value of some item.
final int type = ExpandableListView.getPackedPositionType(packedPosition);
if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
return mGroups.get(ExpandableListView.getPackedPositionGroup(packedPosition))
.children.get(ExpandableListView.getPackedPositionChild(packedPosition))
.name;
} else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
return mGroups.get(ExpandableListView.getPackedPositionGroup(packedPosition))
.name;
} else {
throw new IllegalStateException("packedPosition is not a valid position.");
}
|
private android.view.View | getView(long packedPosition, android.view.View convertView, android.view.ViewGroup parent)Gets a view for the packed position, possibly reusing the convertView.
if (isOutOfBounds(packedPosition)) {
throw new IllegalStateException("position out of range for adapter!");
}
final ExpandableListView elv = getExpandableListView();
final int flPos = elv.getFlatListPosition(packedPosition);
if (convertView != null) {
((TextView) convertView).setText(getValueAtPosition(packedPosition));
convertView.setId(flPos);
return convertView;
}
int desiredHeight = getHeightForPosition(flPos);
return createView(packedPosition, flPos, parent, desiredHeight);
|
protected final void | init(Params params)
init((ExpandableParams) params);
|
protected abstract void | init(com.android.frameworktest.util.ExpandableListScenario$ExpandableParams params)
|
private boolean | isOutOfBounds(long packedPosition)Whether a particular position is out of bounds.
final int type = ExpandableListView.getPackedPositionType(packedPosition);
if (type == ExpandableListView.PACKED_POSITION_TYPE_NULL) {
throw new IllegalStateException("packedPosition is not a valid position.");
}
final int group = ExpandableListView.getPackedPositionGroup(packedPosition);
if (group >= mGroups.size() || group < 0) {
return true;
}
if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
final int child = ExpandableListView.getPackedPositionChild(packedPosition);
if (child >= mGroups.get(group).children.size() || child < 0) {
return true;
}
}
return false;
|
protected void | readAndValidateParams(Params params)
ExpandableParams expandableParams = (ExpandableParams) params;
int[] numChildren = expandableParams.mNumChildren;
mGroups = new ArrayList<MyGroup>(numChildren.length);
for (int i = 0; i < numChildren.length; i++) {
mGroups.add(new MyGroup(numChildren[i]));
}
expandableParams.superSetNumItems();
super.readAndValidateParams(params);
|
protected void | setAdapter(android.widget.ListView listView)
((ExpandableListView) listView).setAdapter(mAdapter = createAdapter());
|