简体   繁体   中英

I want to make a child linear layout invisible during onCreate and then make it visible at the tap of a button

XML Layout Here This is my layout. I want everything after the button to be invisible until the button is tapped.

/**
     * This activity toggles open the order_form layout AFTER "Order" Button is clicked.
     */
    Button properties = (Button) findViewById(R.id.order_button);

// and LinearLayout to toggle
    final LinearLayout propLayout = (LinearLayout) findViewById(R.id.order_form);

    properties.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            propLayout.setVisibility((propLayout.getVisibility() == View.VISIBLE)
                    ? View.INVISIBLE
                    : View.VISIBLE);
        }
    });

place and visibility attribute in xml like so

android:visibility="invisible"

<LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  android:visibility="invisible">

   <-- edittext views here-->
   <EditText
      ......./>
</LinerLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM