How to display number of fragment in a listview item?

0

I am lot wasting my time to search & create some code to development, but not find any solution, I am newer in android. Please help me.

I got following error

Binary XML file line #15: Duplicate id 0x7f07002e, tag 0, or parent id 0xffffffff with another fragment for com.digital.myproject.fragments.CellGroupFragment

this is my list_row.xml

this row item having group of 9 fragments

enter image description here

following is my expandable listview baseadapter

public class ExpandableListAdapter extends BaseExpandableListAdapter implements CellGroupFragment.OnFragmentInteractionListener  {

private Context _context;
private List<String> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<String, List<RawModel>> _listDataChild;

public ExpandableListAdapter(Context context, List<String> listDataHeader,
                             HashMap<String, List<RawModel>> listChildData) {
    this._context = context;
    this._listDataHeader = listDataHeader;
    this._listDataChild = listChildData;
}

@Override
public Object getChild(int groupPosition, int childPosititon) {
    return this._listDataChild.get(this._listDataHeader.get(groupPosition))
            .get(childPosititon);
}

@Override
public long getChildId(int groupPosition, int childPosition) {
    return childPosition;
}

@Override
public View getChildView(int groupPosition, final int childPosition,
                         boolean isLastChild, View convertView, ViewGroup parent) {

    RawModel rawModel = (RawModel) getChild(groupPosition, childPosition);

    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) this._context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.list_item, null);
    }

    ImageView txtDelete = (ImageView) convertView.findViewById(R.id.delete);
    TextView txtLevel = (TextView) convertView.findViewById(R.id.Level);


    int cellGroupFragments[] = new int[]{R.id.cellGroupFragment, R.id.cellGroupFragment2, R.id.cellGroupFragment3, R.id.cellGroupFragment4,
            R.id.cellGroupFragment5, R.id.cellGroupFragment6, R.id.cellGroupFragment7, R.id.cellGroupFragment8, R.id.cellGroupFragment9};
    for (int i = 1; i < 10; i++) {
        CellGroupFragment thisCellGroupFragment = (CellGroupFragment) ((AppCompatActivity) _context).getSupportFragmentManager().findFragmentById(cellGroupFragments[i-1]);
        thisCellGroupFragment.setGroupId(i);
        layout.addView(thisCellGroupFragment);
    }

    return convertView;
}

@Override
public int getChildrenCount(int groupPosition) {
    return this._listDataChild.get(this._listDataHeader.get(groupPosition))
            .size();
}

@Override
public Object getGroup(int groupPosition) {
    return this._listDataHeader.get(groupPosition);
}

@Override
public int getGroupCount() {
    return this._listDataHeader.size();
}

@Override
public long getGroupId(int groupPosition) {
    return groupPosition;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
                         View convertView, ViewGroup parent) {
    String headerTitle = (String) getGroup(groupPosition);
    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) this._context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.list_group, null);
    }

    TextView lblListHeader = (TextView) convertView
            .findViewById(R.id.lblListHeader);
    lblListHeader.setTypeface(null, Typeface.BOLD);
    lblListHeader.setText(headerTitle);

    return convertView;
}

@Override
public boolean hasStableIds() {
    return false;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    return true;
}

@Override
public void onFragmentInteraction(int groupId, int cellId, View view) {

}
}
android
android-fragments
android-listview
android-custom-view
asked on Stack Overflow Feb 8, 2020 by user3315464 • edited Feb 10, 2020 by Kampai

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0