I have a ScrollView with LinearLayout into it.After adding the Layout into my LinearLayout, I wanted to remove the view but it removes only the first view.
I have tried parent.removeView(myView)
My Code for Layout adding :
LayoutInflater inflater = getLayoutInflater();
final View view_top = inflater.inflate(R.layout.layout_top, linear_layout,false);
final View view_bottom = inflater.inflate(R.layout.layout_bottom,linear_layout,false);
final RelativeLayout rel_layout_bottom = (RelativeLayout) view_bottom.findViewById(R.id.relative_bottom);
Button btn_update = (Button) rel_layout_bottom.findViewById(R.id.lst_todo_update);
ImageButton btn_remove = (ImageButton) rel_layout_bottom.findViewById(R.id.lst_btn_delete);
ImageButton btn_Color = (ImageButton) rel_layout_bottom.findViewById(R.id.lst_btn_color);
final RelativeLayout rel_layout_top = (RelativeLayout) view_top.findViewById(R.id.relative_top );
final TextView note_Title = (TextView) rel_layout_top.findViewById(R.id.lst_title );
final TextView note_color = (TextView) rel_layout_top.findViewById(R.id.lst_color_type );
note_Title.setText(note_title);
linear_layout.addView(rel_layout_bottom, 0);
JSONArray jsonArray=queryResult.getResultObjects().get(count).getJSONArray("todo_item");
for (int i = 0; i < jsonArray.length(); i++) {
    final View view_middle  = inflater.inflate(R.layout.layout_middle, linear_layout, false);
    final RelativeLayout rel_layout_middle = (RelativeLayout) view_middle.findViewById(R.id.relative_middle);
    final CheckBox note_check ;
    final TextView note_content ;
    note_content = (TextView) rel_layout_middle.findViewById(R.id.lst_content);
    note_check = (CheckBox) rel_layout_middle.findViewById(R.id.lst_check);
    btn_remove.setOnClickListener(null);
    try {
        //Getting data correctly here
        linear_layout.addView(view_middle,0);
        btn_remove.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {               
               linear_layout.removeView(view_middle);        //Not able to remove the view here i.e view_middle
               linear_layout.removeView(view_top);
               linear_layout.removeView(view_bottom);
            }
        }); 
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
linear_layout.addView(rel_layout_top , 0);
}
Any answer Appreciated...Thks