[ACCEPTED]-How can I hide/show an element when a button is pressed?-hide
Accepted answer
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)
TableLayout tl = (TableLayout)findeViewById(R.id.yourtablelayout);
tl.setVisibility(View.VISIBLE);
Something like that within your onClick()
method 1 should do the trick.
Try:
TableLayout table;
Button button;
table = (TableLayout) findViewById (R.id.tablelayout1);
button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// View list = (View)findViewById(R.id.myviewId);
tbleview.setVisibility(View.INVISIBLE);
}
});
Hope this works.
0
Try this in MainActivity class :
TextView textview;
/* onClick 3 method of show button */
public void show(View view){
textview.setVisibility(View.VISIBLE);
}
/* onClick method 2 of hide button */
public void hide(View view){
textview.setVisibility(View.INVISIBLE);
}
and try this in onCreate 1 method :
textview = (TextView) findViewById(R.id.textview);
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.