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 7760325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:51:26+00:00 2026-06-01T13:51:26+00:00

I have a title bar in my application. And the title bar has one

  • 0

I have a title bar in my application. And the title bar has one button. On click of that button I display info activity. Now, as far as I know, android:onClick needs a reference of a public method inside the activity which has the xml set in setContentView(). Now, as the logic for that buttons click will be the same throughout the application, so what I want is, I will the method just once say showInfoScreen(View view) and put it in that buttons onClick attribute. And I need not write the same method everywhere. Is it possible?

  • 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-01T13:51:27+00:00Added an answer on June 1, 2026 at 1:51 pm

    Of course it’s possible. Write an Activity class, then have all of your Activitys extend it. For example:

    public abstract class BaseActivity extends Activity {
    
        @Override
        public void setContentView( int layoutResID ) {
    
            super.setContentView( layoutResID );
            findViewById(R.id.button).setOnClickListener(new OnTitleBarButtonClickListener());
        }
    
        private void showInfoScreen() {
    
            // Show the info screen
        }
    
        private class OnTitleBarButtonClickListener implements OnClickListener {
    
            @Override
            public void onClick(View v) {
    
                showInfoScreen();
            }
        }
    }
    

    Then all of your derived Activitys would extend BaseActivity instead of Activity.

    The beauty of doing it this way is that any Activity that extends this class automatically gets this feature. No coding is required in the derived classes, just in BaseActivity. The only contract all of your Activitys will have will be to have R.id.button or whatever id you name it within its content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now Im customizing title bar of my application. My aim is to add one
I have two different styles for my window: Regular - window has title bar
I have a panel component on my flex application. This component has a click
iPhone application, which has two buttons -right side- of Navigation Bar title. I want
I have a flash application that utilizes a lot of popup title windows that
I have an application which uses a custom title bar. However, when my application
I want to customize the title bar for an Android application. I have the
Some Windows native applications have a question mark icon on the title bar. It's
My form doesn't have a title bar, so I am implementing the code to
How can I make my window not have a title bar but appear in

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.