Android: click a button to bring up the content that is not (or exists) in the original layout. The following example shows how to delete the original layout content.

Source: Internet
Author: User

Mainly involves (1) monitoring a widget in the layout

(2) set display and delete parameters in the layout File

There are three visibility parameters. Here I only set one, which is visible.

android:visibility="visible"

The rest is the same as its usage.

(3) After listening to the control in the code, reset the visibility parameter.

: The edittext disappears after you click the button.

(1) Before clicking the Advanced button


(2) Click the Advanced button.


(1) Layout File

<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHByZSBjbGFzcz0 = "brush: java;">

(2) sample code:

package com.example.effectone;import android.os.Bundle;import android.provider.Settings.System;import android.R.string;import android.app.Activity;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;import android.widget.Toast;public class MainActivity extends Activity {private EditText   eText = null;private  Button button =null;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);eText = (EditText)findViewById(R.id.serveip);button =(Button)findViewById(R.id.gaoji);button.setOnClickListener(new  OnClickListener() {public void onClick(View v) {Button but=(Button)v;  switch (but.getId()) {case R.id.gaoji:  eText.setVisibility(View.INVISIBLE);default:break;}}});}}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.