• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Eclipse: where is my OnClick() method?

I'm new to developing Android applications, so before I try to build the app that I want to build, I first want to make sure that I can implement all the necessary features that it requires.

One of these features is multiple pages. I'm not sure if this is the best way to do this, but what I'm trying to do is get a button that, when pressed, hides TableLayout1 and shows TableLayout2, the latter of which contains a button that does the opposite so that you can return to TableLayout1.

This is the code I was given on stackoverflow:
Code:
TableLayout tl = (TableLayout)findeViewById(R.id.tableLayout2);

tl.setVisibility(View.VISIBLE);

However, I have no idea as to where to put this. I was told to put it within my OnClick() method, but I have no idea what or where that is. Do I need to create a new activity or something?

Any help is very much appreciated. Thanks!
 
If would use intents to switch between the pages. You'll need an activity for both, with the scond extending the first "public class activity2 extends activity1"
Then put the following in your onClick()
Code:
Intent myIntent = new Intent(activity1.this, activity2.class);
startActivity(myIntent);

And just reverse activity1 and activity2 in the second activity.
 
What steps exactly do I need to take to create the intents? Where do I put "public class activity2 extends activity1?"

Again, where exactly is my OnClick()? I can right-click on the button in Eclipse, go to Properties and click OnClick, but all I get is a one-line textbox, not a textbox that I can put multiple lines of code in.
 
Back
Top Bottom