1. Download our Official Android App: Forums for Android!

Apps Eclipse: where is my OnClick() method?

Discussion in 'Android Development' started by stickynote427, Feb 20, 2011.

  1. stickynote427

    stickynote427 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Feb 20, 2011

    Feb 20, 2011
    2
    0
    5
    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 (Text):
    1.  
    2. TableLayout tl = (TableLayout)findeViewById(R.id.tableLayout2);
    3.  
    4. 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!
     

    Advertisement

  2. cr5315

    cr5315 Android Enthusiast
    Rank:
    None
    Points:
    68
    Posts:
    434
    Joined:
    Jul 23, 2010

    Jul 23, 2010
    434
    158
    68
    Narnia
    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 (Text):
    1. Intent myIntent = new Intent(activity1.this, activity2.class);
    2. startActivity(myIntent);
    And just reverse activity1 and activity2 in the second activity.
     
  3. stickynote427

    stickynote427 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Feb 20, 2011

    Feb 20, 2011
    2
    0
    5
    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.
     

Share This Page

Loading...