Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7714353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:06:22+00:00 2026-06-01T02:06:22+00:00

I have the following scenario: android up, compatible starting with android 1.6 and up.

  • 0

I have the following scenario: android up, compatible starting with android 1.6 and up. At the bottom of ALL activities I have a set of ToggleButtons that only start activities. Don’t ask me why, that was the request 🙂 Having these buttons do the same thing in all screens I thought like this:

  1. Put the layout in a xml file and it in all my activities layout
  2. Create a class that extends Activity and assign onClick methods for all my buttons
  3. When a ToggleButton is checked, set all other buttons checked=”false” and perform the button’s operation.

I am stuck on my BaseActivity, when overriding onCreate(). How do I get a hold of my buttons and assign onClick listeners to them ?

public class BaseActivity extends Activity {
    private ToggleButton menuHome;

    @Override
    public void onCreate(Bundle savedInstanceState) {
             //this does not work as it cannot find R.id.menu_home)
        menuHome = (ToggleButton) findViewById(R.id.menu_home);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:06:23+00:00Added an answer on June 1, 2026 at 2:06 am

    In your other Activities that extend BaseActivity take a look at your OnCreate method. Does it look like this?

    public class YourActivity extends BaseActivity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            base.Oncreate(saveInstanceState);     
    
            setContentView(R.layout.YourLayout);
    
            // Other code here...
        }
    }
    

    It has to do with the order… you haven’t set the content view so your toggle button doesn’t exist. Try this:

    public class YourActivity extends BaseActivity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            setContentView(R.layout.YourLayout); // Set your content view first.
    
            base.Oncreate(saveInstanceState);     
    
    
    
            // Other code here...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenario. The client code only has access to FooHandler, not
I have the following scenario that may warrant storing data in a conroller member
The scenario is the following: I have an activity RunTrainingWorkoutsView that uses XML layout
I just encountered the following situation. I have an Android app with a scenario
I have the following scenario (note that activity A has launchMode=singleTop ): Activity A
I have following scenario: The Android clients communicate with a PHP server via HTTP
I have the following Android scenario: my activity launches an asynchronous task to perform
I have the following scenario. I have one table in the database A that
I have the following dilemma, I have an Android Application that POST a request
I have the following scenario: Entities are loaded from the database. One of them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.