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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:44:00+00:00 2026-06-04T11:44:00+00:00

I am working on a header for an app. The header will have 4

  • 0

I am working on a header for an app. The header will have 4 buttons. Each button will have a listener and some code to send it to the home of that button.

The Java code for the buttons will be the same so I am wondering what I can do so that I can have that code in one place and reuse it in all my screens. How do people typically handle this kind of a scenario? Should/can I make a utility class and just import that? If I do, then how do I handle code like this so it would know which intent I am on?

          Intent myIntent = new Intent(CurrActivity.this, NextActivity.class);
          CurrActivity.this.startActivity(myIntent);

Thanks!

  • 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-04T11:44:01+00:00Added an answer on June 4, 2026 at 11:44 am

    A couple of options I can think of:-

    • Have an ActivityBase class or a FragmentBase class that you put all your navigation logic into, all your activities/fragments would subclass from this, therefore share the same nav logic
    • Create a custom view based of LinearLayout or ViewGroup, treat each child view of this custom view as a navigation item, this might be a bit heavy depending on your experience but definetly the way I would do it these days, info here on custom views http://developer.android.com/guide/topics/ui/custom-components.html

    With both options you should look at the include tag that will allow you to share the xml that defines your navigation across layouts.

    http://developer.android.com/resources/articles/layout-tricks-reuse.html

    Hope that helps.

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

Sidebar

Related Questions

I have written some code in Java that will decode a SHOUTcast stream and
I have a simple BlackBerry app i'm working on that uses JSONP and Zepto.js.
I'm working on an app that needs to be able to send out email
First off, I'm working on an app that's written such that some of your
I am working on a web app using MVC, where all pages have header
I'm working on a new layout for my site that uses a header, footer
Greetings, I'm working on a JS-based application that does some complex work and logs
I have a REST service that's reasonably complete and will be used with an
I'm writing a Cocoa app that will need access to multiple file transfer protocols,
I'm working on a very simple Firefox extension that will log info and dynamically

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.