1. HUGE Androidforums.com UPDATE! Learn what's new (and download the new app!)
    Dismiss Notice

Buttons And Tabs

Last Updated:

  1. Iguy29

    Iguy29 Member This Topic's Starter

    Jun 19, 2010
    Likes Received:
    I am working on an app, and i have a strange problem. In my main class (Event) it extends tabactivity, because it needs to initialize the tabs. So in my 2nd class (buttonManager) i have the code for when the buttons are pressed that they will switch the view to the appropriate layout. The buttonManager still has the blurb of code:
    public void onCreate(Bundle savedInstanceState) {
    i tried removing the @Override, it doesn't work, and i tried moving the code to Event, but it doesn't work, because it extends tabactivity, not activity. I am wondering if it is a problem that my buttons aren't in the main one, or if there is any way for my main class to extend both activity and tab activity.
    Here is the code for buttonmanager, the class that handles the buttons if you are interested to see how it looks:
    Code (Text):
    1. package com.dev.ir.im;
    3. import android.app.Activity;
    4. import android.content.Intent;
    5. import android.os.Bundle;
    6. import android.view.View;
    7. import android.view.View.OnClickListener;
    9. public class buttonManager extends Activity implements OnClickListener {
    10.     @Override
    11.        public void onCreate(Bundle savedInstanceState) {
    12.           super.onCreate(savedInstanceState);
    13.           setContentView(R.layout.input);
    15.           // Clicklistener setup
    16.           View stretcher = findViewById(R.id.stretchbutton);
    17.           stretcher.setOnClickListener(this);
    18.           View yoga = findViewById(R.id.yogabutton);
    19.           yoga.setOnClickListener(this);
    20.           View arms = findViewById(R.id.armbutton);
    21.           arms.setOnClickListener(this);
    22.           View legs = findViewById(R.id.legworkouts);
    23.           legs.setOnClickListener(this);
    24.           View core = findViewById(R.id.corebutton);
    25.           core.setOnClickListener(this);
    26.           View other = findViewById(R.id.otherbutton);
    27.           other.setOnClickListener(this);
    28.           View timer = findViewById(R.id.timerbutton);
    29.           timer.setOnClickListener(this);
    30.        }
    31.     public void onClick(View v) {
    32.         switch (v.getId()) {
    33.           case R.id.timerbutton:
    34.              onTimerClick();
    35.              break;
    37.           }
    38.        }        
    39.     public void onTimerClick() {
    40.         Intent ti = new Intent(this, chrono.class);
    41.         startActivity(ti);
    42.         }
    43.     }
    I know that all of the cases aren't coded in yet, but the one that is doesn't work, so i decided not to put anything else in yet until it's fixed.
    The chrono class just is the set view code.


Share This Page