How can I hide / show an item when a button is clicked?

I am trying to learn how to develop Android using the Eclipse IDE. What I'm trying to do right now is that the hidden TableLayout panel is visible when the button is clicked. However, I do not know what I need to add the OnClick property.

Also, are there any online tutorials that can help me learn how to develop Android applications in Eclipse?

Thanks!

+7
source share
3 answers

just use the TableLayout link using findViewById(int) in onClickListener() . if you have a TableLayout object, call setVisibility(View.VISIBLE)

+13
source
 TableLayout tl = (TableLayout)findeViewById(R.id.yourtablelayout); tl.setVisibility(View.VISIBLE); 

Something like this in your onClick() method should do the trick.

+11
source

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.

+5
source

All Articles