ExpandableListView with multiple layouts

I apologize for my English, but translated using Google. I need help for my application, I use ExpandableListView with three different layouts, but I am having problems not finding the answer in different forums. Basically, if the getChildView () method checks to see if the conversion is zero, I shift all layouts or even repeat them several times. If I do not do this check, you will see the layout as it should, but the values ​​in the EditText are erased if I click on another group, or if you look at the list until you see more layout using EditText. I hope I was clear enough, and I hope the answers are equally clear, unfortunately I was everywhere on the Internet, but could not find the answer I was looking for. Thanks in advance to those who will help me.

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

            View view = convertView;
            ViewHolder holder;

            if (view == null) {
                    holder = new ViewHolder();

                    if (groupPosition == 0) {
                            convertView = infalInflater.inflate(R.layout.adv_item, null);
                            holder.btn1 = (ImageButton) convertView
                                            .findViewById(R.id.button1);
                            holder.btn2 = (ImageButton) convertView
                                            .findViewById(R.id.button2);
                            holder.btn3 = (ImageButton) convertView
                                            .findViewById(R.id.button3);
                            holder.et1 = (EditText) convertView.findViewById(R.id.editText1);
                            holder.et2 = (EditText) convertView.findViewById(R.id.editText2);
                            holder.et3 = (EditText) convertView.findViewById(R.id.editText3);
                            holder.et4 = (EditText) convertView.findViewById(R.id.editText4);
                            holder.et5 = (EditText) convertView.findViewById(R.id.editText5);
                            holder.et6 = (EditText) convertView.findViewById(R.id.editText6);
                            holder.check_sc1 = (CheckBox) convertView
                                            .findViewById(R.id.item_check_sc1);
                            holder.check_sc2 = (CheckBox) convertView
                                            .findViewById(R.id.item_check_sc2);
                            holder.check_sc3 = (CheckBox) convertView
                                            .findViewById(R.id.item_check_sc3);
                            holder.check_oo = (CheckBox) convertView
                                            .findViewById(R.id.item_check_oo);
                            convertView.setTag(holder);
                    }
                    if (groupPosition == 1) {
                            convertView = infalInflater.inflate(R.layout.visual_item, null);
                    }
                    if (groupPosition == 2) {
                            convertView = infalInflater.inflate(R.layout.routes_item, null);
                    }
            } else {
                    holder = (ViewHolder) convertView.getTag();
            }
            return convertView;
    }
+4
1

"", . "", , :

@Override
public int getViewTypeCount() {
    return 3;     // <-- Here goes your view types count
}

, , :

@Override
public int getItemViewType(int position) {
    return getItemViewType(position);  // <-- Here must be your logic to get the type of the item
}

, Android , . "if (groupPosition == 2)" ( ..), ListView getView(). ListAdapters.

ExpandableAdapters, :

public int getGroupTypeCount ()
public int getGroupType (int groupPosition)
public int getChildType (int groupPosition, int childPosition)
public int getChildTypeCount ()

, , . , - :

@Override
public int getChildTypeCount () {
    return 3;   <-- you have three types of views
}

@Override
public int getChildType (int groupPosition, int childPosition) {
    /*
     * In case of group 1 this function returns 1,
     * in case of group 2 it returns 2, and so on.
     */
    return groupPosition;
}
+12

All Articles