I'm trying to learn how to develop Android using the Eclipse IDE. What I'm trying to do right now is make a hidden TableLayout visible when a button is pressed. However, I have no idea as to what I need to put in the button's OnClick property.
Also, are there any tutorials online that could help me learn how to develop Android apps in Eclipse?
Thanks!
well just take the reference of the TableLayout by using findViewById(int)
in the onClickListener()
. once you have the object of TableLayout, call setVisibility(View.VISIBLE)
TableLayout tl = (TableLayout)findeViewById(R.id.yourtablelayout);
tl.setVisibility(View.VISIBLE);
Something like that within your onClick()
method 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.
Try this in MainActivity class :
TextView textview;
/* onClick method of show button */
public void show(View view){
textview.setVisibility(View.VISIBLE);
}
/* onClick method of hide button */
public void hide(View view){
textview.setVisibility(View.INVISIBLE);
}
and try this in onCreate method :
textview = (TextView) findViewById(R.id.textview);