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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:30:24+00:00 2026-06-07T02:30:24+00:00

I have this layout, containing a single TextView , but I would like to

  • 0

I have this layout, containing a single TextView, but I would like to be able to change it’s content (the text to be visualized) in a dynamic way, using java code.

<LinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

     <TextView 

        android:id="@+id/list_header"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center_vertical"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:textStyle="bold"
        android:textSize="22dp"
        android:textColor="#FFFFFF"
        android:padding="10dp"
        android:background="#336699" 

     />

</LinearLayout>

As you can see I have not defined the android:text="blablabla" cause it is not fixed at the point of the code in which I use it.

I would like some method such as:

TextView headerValue = (TextView) findViewById(R.id.list_header);
headerValue.setText( "blablabla" );

but this won’t work because I use this layout for defining the style of a header of the list, and these lines conflict with the following I need to use:

View header = (View)getLayoutInflater().inflate(R.layout.list_header_layout, null);
listView.addHeaderView(header);

Can you please help me fix this problem?


LOGCAT:

E/AndroidRuntime( 1468):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 1468):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime( 1468):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime( 1468):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime( 1468):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1468):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 1468):    at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 1468):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1468):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 1468):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 1468):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 1468):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1468): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.DVA_HLUI/com.DVA_HLUI.DVA_HLUISuperviseActivity}: java.lang.NullPointerException
E/AndroidRuntime( 1468):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 1468):    at android.app.ActivityThread.startActivityNow(ActivityThread.java:1797)
E/AndroidRuntime( 1468):    at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
E/AndroidRuntime( 1468):    at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
E/AndroidRuntime( 1468):    at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:682)
E/AndroidRuntime( 1468):    at android.widget.TabHost.setCurrentTab(TabHost.java:346)
E/AndroidRuntime( 1468):    at android.widget.TabHost.addTab(TabHost.java:236)
E/AndroidRuntime( 1468):    at com.DVA_HLUI.DVA_HLUIActivity.onCreate(DVA_HLUIActivity.java:41)
E/AndroidRuntime( 1468):    at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime( 1468):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime( 1468):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime( 1468):    ... 11 more
E/AndroidRuntime( 1468): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 1468):    at com.DVA_HLUI.DVA_HLUISuperviseActivity.onCreate(DVA_HLUISuperviseActivity.java:41)
E/AndroidRuntime( 1468):    at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime( 1468):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime( 1468):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime( 1468):    ... 21 more

Activity Class:

public class MyActivity extends ListActivity 
{

    @Override
    protected void onCreate(Bundle savedInstanceState) 
    { 

        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_activity);

        ListView listView = (ListView) findViewById(android.R.id.list);

        listEntryClass listEntries[] = new listEntryClass[]
        {
            new listEntryClass( "bla", "bla"),
            new listEntryClass( "bla", "bla" )
        };

        listEntryArrayAdapter adapter = new listEntryArrayAdapter(this, R.layout.list_entry_layout, listEntries);

        TextView headerValue = (TextView) findViewById(R.id.list_header);
        headerValue.setText( this.getString(R.string.headerSupervise) );

        View header = (View)getLayoutInflater().inflate(R.layout.list_header_layout, null);
        listView.addHeaderView(header);
        listView.setAdapter(adapter);
}
  • 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-07T02:30:25+00:00Added an answer on June 7, 2026 at 2:30 am
    TextView headerValue = (TextView) header.findViewById(R.id.list_header);
    

    Should be referenced from header view.

    So Change your code to follwing.

        View header = (View)getLayoutInflater().inflate(R.layout.list_header_layout, null);
        TextView headerValue = (TextView) header.findViewById(R.id.list_header);
        headerValue.setText( this.getString(R.string.headerSupervise) );
    
        listView.addHeaderView(header);
        listView.setAdapter(adapter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this layout that works correctly, a relative layout with a text view
I have an item layout like this, and set the background by using item
I have an interesting content layout proposal but I'm having difficulty figuring out how
I have this layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=wrap_content android:layout_height=wrap_content > <TextView android:id=@+id/solution_title
I have this layout: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=horizontal android:layout_width=fill_parent android:layout_height=fill_parent android:background=#222222 android:gravity=center_horizontal android:layout_gravity=center_horizontal android:paddingBottom=5dp> <SeekBar
So, I have this layout: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/layout android:layout_width=fill_parent android:layout_height=wrap_content android:background=#FFFF00
I have this table layout: uuid bigint(20) unsigned primary auto_increment timestamp int(11) unsigned name
I have this code snippet in an email layout: <div> <?php echo $this->Html->image('Layouts/default/Logo.png', array(
I have designed the screen using this relative layout. <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android
I have a linear layout with this form <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical

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.