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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:24:49+00:00 2026-06-04T03:24:49+00:00

When we make Android layout in XML, we can use include to make some

  • 0

When we make Android layout in XML, we can use include to make some other layout the part of the host layout. Is there such thing for Java class?

I am attaching a top bar layout to every screen and it contains buttons. Now in every Java class I have to copy/paste the initialization code.

Is there any shortcut for such scenarios? Can Application class facilitate anyhow? If anyone has a working solution, please share it with me.

For example, in XML I can use

//...xml layout elements
<include layout="@layout/topbar" />
//...some other xml layouts

so it would be cool to be able to use in Java code something where I could instantly initiate buttons, register onClick events and set actions to these events. It all the same piece of code I am using, after all.

  • 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-04T03:24:50+00:00Added an answer on June 4, 2026 at 3:24 am

    Make an activity (BaseActivity) with the implementation you desire and just extend this class in your other activities.

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

Sidebar

Related Questions

In android SDK, when I editing an android layout xml file, it can do
I want to make use of the android xml layouts. I have put a
I have to make a simple layout in android but have problem with the
I was wondering if there was a way to make Android games in libgdx
I have the following layout in main.xml : <?xml version=1.0 encoding=utf-8?> <FrameLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
Can i set setOnItemClickListener if i can't make list view.setonitemcliclistener because mi xml code
I'm trying to make an Android layout: 3 components inside a vertical LinearLayout. The
I have a general question regarding Android's separation of layouts into layout.xml files: My
I have the following layout: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent> <GridView android:id=@+id/grid
How to make android EditText smaller than default in height? If I change the

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.