I do not know why my extensible calls getChildView () and getGroupView () many times. The problem affects application performance. Please help me, here is this adapter.
public class ResultsExpandableAdapter extends BaseExpandableListAdapter { private Context mContext; private ArrayList<TraceGroupObject> groups; private int displayMode; private String TAG = "EXPAND LIST NUTRIENT"; public ResultsExpandableAdapter(Context context, ArrayList<TraceGroupObject> groups, int displayMode) { this.mContext = context; this.groups = groups; this.displayMode = displayMode; } @Override public Object getChild(int groupPosition, int childPosition) { ArrayList<TraceObject> group = groups.get(groupPosition).getItems(); return group.get(childPosition); } @Override public long getChildId(int groupPosition, int childPosition) {
getChildView code
// bug @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { // Log.i(TAG, "Child View (" + groupPosition + "," + childPosition // + ") ->" + convertView); final TraceObject trace = (TraceObject) getChild(groupPosition, childPosition); View row; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) mContext .getSystemService(mContext.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.expandable_row_item, null); // Log.i(TAG, "Created View ->" + convertView); } else row = convertView; // init tracebar ... // implement return row; }
hix hix
@Override public int getChildrenCount(int groupPosition) { ArrayList<TraceObject> rows = groups.get(groupPosition).getItems(); return rows.size(); } @Override public Object getGroup(int groupPosition) { // TODO Auto-generated method stub return groups.get(groupPosition); } @Override public int getGroupCount() { // TODO Auto-generated method stub return groups.size(); } @Override public long getGroupId(int groupPosition) { // TODO Auto-generated method stub return groupPosition; }
ac ac getGroupView
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { // Log.i(TAG, "Group View "+groupPosition +"->" +convertView); TraceGroupObject group = (TraceGroupObject) getGroup(groupPosition); // create view View row; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) mContext .getSystemService(mContext.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.expandable_group_item, null); // Log.i(TAG, "Created View ->" +convertView); } else row = convertView; // change icon expand ... return row; } @Override public boolean hasStableIds() { // TODO Auto-generated method stub return true; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { // TODO Auto-generated method stub return false; }
source share