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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:19:14+00:00 2026-05-11T17:19:14+00:00

I am using a custom title view in my application for each activity. In

  • 0

I am using a custom title view in my application for each activity. In one of the activities, based on button clicks I need to change the custom title view. Now this works fine every time when I make a call to setFeatureInt.

But if I try to update any items in the custom title (say change the text of a button or a text view on the title), the update does not take place.

Debugging through the code shows that the text view and button instances are not null and I can also see the custom title bar. But the text on the text view or the button is not updated. Has anyone else faced this problem?
How do I resolve it?

Thanks.

EDIT

Here’s what I tried. Does not get updated even on calling postInvalidate.

    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.text_title);

    TextView databar = (TextView) findViewById(R.id.title_text);
    databar.setText("Some Text");
    databar.postInvalidate();

    Button leftButton = (Button) findViewById(R.id.left_btn);
    leftButton.setOnClickListener(mLeftListener);
    leftButton.setText("Left Btn");
    leftButton.postInvalidate();

    Button rightBtn = (Button) findViewById(R.id.right_btn);
    rightBtn.setOnClickListener(mRightListener);
    rightBtn.postInvalidate();
  • 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-11T17:19:14+00:00Added an answer on May 11, 2026 at 5:19 pm

    The problem is that the only Window implementation (PhoneWindow) uses a LayoutInflater in its setFeatureInt method and instantiates the new layout with inflate and attachToRoot=true. Consequently, when you call setFeatureInt, the new layouts are not replaced but attached to the internal title container and thus drawn on top of each other.

    You can workaround this by using the following helper method instead of setFeatureInt. The helper simply removes all views from the internal title container before the new custom title feature is set:

    
    private void setCustomTitleFeatureInt(int value) {
        try {
            // retrieve value for com.android.internal.R.id.title_container(=0x1020149)
            int titleContainerId = (Integer) Class.forName(
                "com.android.internal.R$id").getField("title_container").get(null);
    
            // remove all views from titleContainer
            ((ViewGroup) getWindow().findViewById(titleContainerId)).removeAllViews();
    
            // add new custom title view 
            getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, value);
    
        } catch(Exception ex) {
            // whatever you want to do here..
        }
    }
    

    I’m not sure whether the current setFeatureInt behaviour is intended, but it is certainly not documented one way or the other which is why I’ll take this to the android devs 😉

    EDIT

    As pointed out in the comments, the aforementioned workaround is not ideal. Instead of relying on the com.android.internal.R.id.title_container constant you could simply hide the old custom title whenever you set a new one.

    Let’s assume you have two custom title layouts:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout android:id="@+id/custom_title_1" ...
    

    and

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout android:id="@+id/custom_title_2" ...
    

    and you want to replace custom_title_1 with custom_title_2, you could hide former and use setFeatureInt to add the latter:

    findViewById(R.id.custom_title_1).setVisibility(View.GONE);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I'm using a Navigation Controller to push one view that loads
For an application I'm developing, I need to display a custom back button in
I have a custom server control with a property of Title. When using the
I'm using a custom-built inhouse application that generates a standard set of reports on
I am using some custom controls one of which is a tooltip controller that
We are using a custom FTP application (which encrypts the files) for secure transfers.
One of the components I need for an application I am working on is
The problem is mostly summed up in the title. I am using the custom
I'm using a custom view which has a background picture and is used to
Hi I am developing one app using the below link Custom ListView With Headers

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.