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

  • Home
  • SEARCH
  • 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 5846383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:34:08+00:00 2026-05-22T12:34:08+00:00

In my app I have a navigation menu that is constant between activities. To

  • 0

In my app I have a navigation menu that is constant between activities. To make my code a bit easier to modify I made it into its own xml and have been importing it my layouts for each of my screens.

To setup the buttons I made a class which I pass my current Activity. The new class has no problem finding the views for the buttons but cannot find the encapsulating layout for the menu and returns null when I try to findViewById(). Since the buttons and layout are in the same XML

public static void setup(Activity a){
    myActivity = a;

    //OFFENDING BIT OF CODE
    View myLayout = (View) myActivity.findViewById(R.layout.navigation_bar); 

    Log.d(TAG, "layout: "+myLayout);

    set_btn = (ImageButton) myActivity.findViewById(R.id.a_settings);
    set_btn.setPressed(false);
    set_btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //TODO:
        }
    });

    inbox_btn = (ImageButton) myActivity.findViewById(R.id.a_offers);
    inbox_btn.setPressed(false);
    inbox_btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //TODO:
        }
    });

}

Main Screen XML

<RelativeLayout android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:id="@+id/navigationBar"
    android:layout_alignParentBottom="true">
    <include android:layout_height="wrap_content"
        android:id="@+id/include1"
        layout="@layout/navigation_bar"
        android:layout_width="wrap_content"></include>
</RelativeLayout>

Menu XML

<RelativeLayout mlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/NavigationLayout">

    <RelativeLayout android:id="@+id/buttonLayout" 
        android:layout_height="75dip" 
        android:layout_width="fill_parent"  
        android:layout_alignParentBottom="true">

        <ImageButton android:id="@+id/a_settings" 
            android:layout_width="100dip"
            android:background="@drawable/settings_button" 
            android:layout_centerHorizontal="true" 
            android:layout_centerVertical="true"
            android:layout_height="fill_parent"
            android:scaleType="fitXY">
        </ImageButton>

        <ImageButton android:id="@+id/a_wallet" 
            android:layout_width="100dip" 
            android:background="@drawable/wallet_button" 
            android:layout_toLeftOf="@+id/a_settings" 
            android:layout_alignBottom="@+id/a_settings"
            android:layout_height="fill_parent"
            android:scaleType="fitXY">
        </ImageButton>

        <ImageButton android:id="@+id/a_offers" 
            android:layout_width="100dip" 
            android:background="@drawable/offers_button" 
            android:layout_toRightOf="@+id/a_settings" 
            android:layout_alignBottom="@+id/a_settings" 
            android:layout_height="fill_parent"
            android:scaleType="fitXY">
        </ImageButton>

    </RelativeLayout>

</RelativeLayout>
  • 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-05-22T12:34:09+00:00Added an answer on May 22, 2026 at 12:34 pm

    Even though your menu layout is indeed called navigation_bar, you gave your included menu layout the id of include1 -> android:id="@+id/include1". Try findViewById(R.id.include1) if you want to resolve it in your activity (or just try to find the ImageButtons, they are also visible).

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

Sidebar

Related Questions

I have created a flexible navigation bar in my app that will show custom
I have an iPhone app that is based on a navigation controller. I have
Im writing an app that has a navigation controller as it's main menu system
I have a django app that has a horizontal navigation. For some reason I
I have an iPad app that has linear navigation with a Navigation Controller. I
I have a navigation-based app and say my root controller A causes a viewController
I have an app with navigation controller , but my app also has a
I have an app whose navigation tree is described on the attached image. Basically,
I have a tab navigation page in my rails app which is shared across
I have an app, which has a top navigation bar and a bottom tab

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.