1. Are you ready for the Galaxy S20? Here is everything we know so far!

Apps Eclipse: where is my OnClick() method?

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

  1. stickynote427

    stickynote427 Lurker
    Thread Starter

    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

    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

    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.
     
Loading...
Similar Threads - Eclipse where OnClick
  1. Cyberdev
    Replies:
    0
    Views:
    158
  2. Cyberdev
    Replies:
    0
    Views:
    106
  3. Cyberdev
    Replies:
    0
    Views:
    98
  4. Cyberdev
    Replies:
    1
    Views:
    2,385
  5. Cyberdev
    Replies:
    1
    Views:
    1,033
  6. Cyberdev
    Replies:
    4
    Views:
    1,379
  7. Cyberdev
    Replies:
    15
    Views:
    11,905
  8. Cyberdev
    Replies:
    5
    Views:
    5,924
  9. Cyberdev
    Replies:
    1
    Views:
    2,013
  10. Cyberdev
    Replies:
    0
    Views:
    195

Share This Page

Loading...