0

Morning!, I don't know, how can I do to fill a dynamic custom base adapter?, this is an example of my code:

public class Row{
private Context context;
private CheckBox checkbox;
private String kind;

    public Row(Context context, String kind){
        this.context = context;
this.kind=kind;

    }

public start(){
  checkbox = new CheckBox(context);
}

public View getView(){
  View ch=getCheckbox();
  return ch;
}

public CheckBox getCheckbox(){
   return checkbox;
}

public String getKind(){
return kind;
}
}

public class Adapterd extends baseAdapter{
private Context context;
private ArrayList<Line> info;

  public Adapterd(Context context, ArrayList info){
 this.info=info;
 this.context=context;

 }

public View getView(int position, View convertView, ViewGroup parent) {
   View vi = convertView;

        inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        if(info.get(position).getKind().equalsIgnoreCase("text")){
            vi = inflater.inflate(R.layout.adaptador_blank, null);
        }else{vi = inflater.inflate(R.layout.adaptador_checkbox, null);

checkLayout = (RelativeLayout) vi.findViewById(R.id.checkLayout);
checkLayout.addView(info.get(position).getCheckbox());
            }
   }
return vi;
}
}

public class Start{
private ListView content;

public void process(){
   ArrayList<Line> l = new ArrayList<Line>();
   l.add(new Line(this, "checkbox"));
  l.add(new Line(this, "text"));

  Adapterd adapt = new Adapterd(this, l);
content = (ListView) findViewById(R.id.layout2);
content.setAdapter(adapt);

}
}

Sometimes when I add a lot of checkboxes, when they are below of the screen view the value is erased, the fields are switching and repeting and I get Specified child already has a parent here:checkLayout.addView(info.get(position).getCheckbox()); I guess.

I want to manage multiple diferent layouts in my baseAdapter.

user1893074
  • 103
  • 1
  • 3

0 Answers0