[ACCEPTED]-How can I hide/show an element when a button is pressed?-hide

Accepted answer
Score: 16

well just take the reference of the TableLayout 2 by using findViewById(int) in the onClickListener(). once you have the object 1 of TableLayout, call setVisibility(View.VISIBLE)

Score: 14
TableLayout tl = (TableLayout)findeViewById(R.id.yourtablelayout);


Something like that within your onClick() method 1 should do the trick.

Score: 6


TableLayout table;
Button button;
table = (TableLayout) findViewById (R.id.tablelayout1);
button = (Button) findViewById(R.id.button1);

button.setOnClickListener(new OnClickListener() {

    public void onClick(View arg0) {

        // View list = (View)findViewById(R.id.myviewId); 


Hope this works.


Score: 0

Try this in MainActivity class :

  TextView textview;

/* onClick 3 method of show button */

  public void show(View view){


/* onClick method 2 of hide button */

public void hide(View view){

and try this in onCreate 1 method :

    textview = (TextView) findViewById(R.id.textview);

More Related questions