tags:

views:

21

answers:

1

Hello All. I am new to Android.Can anyone give some ideas for my problem.

    /* Parent Linear Layout */

    final LinearLayout par_layout=new LinearLayout(this);
    par_layout.setOrientation(LinearLayout.VERTICAL);

    /* Child Linear Layout */
    final LinearLayout chl_layout=new LinearLayout(this);
    chl_layout.setOrientation(LinearLayout.VERTICAL);

    TextView tv_name=new TextView(this);
    tv_name.setText("Name ");

    TextView tv_item=new TextView(this);
    tv_item.setText("Items ");

    Button btn_submit=new Button(this);
    btn_submit.setText("Submit");
    btn_submit.setOnClickListener(new OnClickListener() {           
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            par_layout.removeAllViewsInLayout();                
        }
    });

    chl_layout.addView(tv_name);
    chl_layout.addView(tv_item);
    chl_layout.addView(btn_submit);        
    par_layout.addView(chl_layout); 
    setContentView(par_layout);

In the above code at the time of button click i wish to clear the chl_layout from the par_layout.But i can't . Can anyone give some ideas ??

Note : The following code also not working

 par_layout.removeView(chl_layout);
A: 

Use below code to remove child view from parent view.

 par_layout.removeView(chl_layout);
Maneesh
I already Use this but it's not remove the chl_layout
Alex