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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:36:14+00:00 2026-06-09T12:36:14+00:00

I have made a custom title bar for my floating activity. Now I want

  • 0

I have made a custom title bar for my floating activity.
Now I want to change text of TextView in my custom title programmatically, but unable to do so.
I can change text via xml, but i want it to do in code.

here is code of label.java(floating activity) which is not updating textView in titlebar

    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);


       requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

       setContentView(R.layout.my_title);
        TextView label = (TextView)findViewById(R.id.myTitle);
        label.setText("Label here code");//not working
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_title);

        setContentView(R.layout.label);// as i need this layout for rest of activity

    //rest of code

myTitle.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myTitle"
android:text="Label here"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="@android:color/white"
 /> 
  • 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-09T12:36:15+00:00Added an answer on June 9, 2026 at 12:36 pm

    Your’e doing it wrong. You have to do it like this:

    public class CustomTitleActivity extends Activity {
        private TextView title;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    
            setContentView(R.layout.label);
    
            getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_title);
    
            title = (TextView) findViewById(R.id.title);
            title.setText("My custom title");
        }
    }
    

    You were trying to inflate your custom title layout into the content area of your Activity with setContentView(R.layout.my_title), which of course lets you grab the TextView because you inflated it into the container, but then you told it to inflate your custom title into the Window, which inflated an entirely different TextView which is actually the one you want. Then you overwrote the content of the Activity with setContentView(R.layout.label).

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

Sidebar

Related Questions

Hello people I have made a custom title bar for my app. I would
I made a custom title bar that I want to appear over all the
I have made one custom ListView but it is not calling any onclick listener
i made one script from here but now i have problem with geting $_POST['file']
I have 2 custom type made with CCK : Reunion Title Description Node reference
I have cells in UITableView , I have made custom frame for the label
I have made a custom form in a module where I have used a
I have made a custom formwizard and incorporated it into my admin interface. Basically
I have made my custom module in magento, in which I have set discount
I have made a custom suface button according this example: <Button> <Button.Template> <ControlTemplate TargetType=Button>

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.