Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable all content inside linear layout in android?

Hi I want to disable all content of linear layout by when activity is loaded , when user click on that are , it display alert msg .

After click on activate button , linear layout should be enabled. Whether it is possible or not?

I am able to disable all content inside linear layout using following code:

LinearLayout myLayout = (LinearLayout) findViewById(R.id.linearLayout1);
for ( int i = 0; i < myLayout.getCount();  i++ ){
    View view = myLayout.getChildAt(i);
    view.setVisibility(View.GONE); // Or whatever you want to do with the view.
 }

I want to display alert dialog when user click on disabled area.

please suggest me usable link or sample code.

like image 455
Sushant Bhatnagar Avatar asked Jan 31 '12 14:01

Sushant Bhatnagar


People also ask

How do you delete a view in linear layout?

Simply Use linearLayout. removeView(View view); It would refresh automaically.

Can we use linear layout in RelativeLayout inside?

We can use LinearLayout inside RelativeLayout. We can also use RelativeLayout as a Child of LinearLayout.

How do I change the layout of my Android phone?

Convert a view or layoutClick the Design button in the top-right corner of the editor window. In the Component Tree, right-click the view or layout, and then click Convert view.... In the dialog that appears, choose the new type of view or layout, and then click Apply.


1 Answers

You need to do as follows:

LinearLayout myLayout = (LinearLayout) findViewById(R.id.linearLayout1);
for ( int i = 0; i < myLayout.getChildCount();  i++ ){
    View view = myLayout.getChildAt(i);
    view.setEnabled(false); // Or whatever you want to do with the view.
 }

Then create an alert Dialog and then

myLayout.setOnclickListener(new OnClickListener(){

   onClick(){
     dialog.show();
   }
});
like image 142
Anand Tiwari Avatar answered Sep 19 '22 21:09

Anand Tiwari