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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:10:00+00:00 2026-06-14T22:10:00+00:00

I am getting the java.lang.NullPointerException on createTabContent for the following code. There are two

  • 0

I am getting the java.lang.NullPointerException on createTabContent for the following code. There are two tabspecs. When I called and set the tab , changed the tabs for the first time it is ok. But when i called again while I am on the second tab, its hit the null pointer exception for line : NoStudentText.setVisibility(View.VISIBLE);

I will show No Student Text if there is no data for the student list. It shows the text for the first time call. But If I do second time call to that tab, got the error.

tspecStudent.setContent(new TabContentFactory() {
            public View createTabContent(String arg0) {
                if(listStudent != null && listStudent .size() > 0) {
                    //show the student list
                } else {
                    TextView noStudentText = (TextView)findViewById(R.id.NoStudentText);
                    noStudentText.setVisibility(View.VISIBLE);
                    return noStudentText;
                }

            }
        });

I am including another xml to the main layout.

main.xml

<TabHost
        android:id="@+id/tabhostMain"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1" > 
....
<include layout="@layout/tab_student" />

</TabHost>

tab_student.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabcontent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

 <ListView
        android:id="@+id/StudentList"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:drawSelectorOnTop="false" />

<TextView
        android:id="@+id/NoStudentText"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="No Student"
        android:visibility="gone" />

</FrameLayout>
  • 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-14T22:10:01+00:00Added an answer on June 14, 2026 at 10:10 pm

    Some times because of yours applied condition it couldn’t able to initialize so,
    Make this variable as global like–

        TextView _noStudentText;
    

    Initialize it in onCreate method::

       _noStudentText = (TextView)findViewById(R.id.NoStudentText);
    

    Now change the visibility according to your need like this–

        _noStudentText.setVisibility(View.VISIBLE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me why am i getting error message java.lang.NullPointerException in following code??
I am getting below error. java.lang.NullPointerException 11-14 16:46:59.093: E/AndroidRuntime(4064): at android.content.ContextWrapper.getContentResolver(ContextWrapper.java:90) Using below code.
Getting the following error : java.lang.NullPointerException: Module 'null' not found. <?xml version=1.0 encoding=UTF-8 ?>
I am getting this error when i use a string array java.lang.NullPointerException The code
I am getting following error while integrating primefaces-extensions dynaform java.lang.NullPointerException at org.primefaces.extensions.component.dynaform.DynaFormRenderer.preRenderLabel(DynaFormRenderer.java:280) at org.primefaces.extensions.component.dynaform.DynaFormRenderer.encodeMarkup(DynaFormRenderer.java:99)
I'm getting an error that says java.lang.NullPointerException: null from a code whenever I run
I'm getting the following NullPointerException: Exception in thread AWT-EventQueue-0 java.lang.NullPointerException at com.foo.JawsFileChooser.a(SourceFile:28) at com.foo.JawsFileChooser$1.actionPerformed(SourceFile:91)
I am getting the following exception Exception in thread AWT-EventQueue-0 java.lang.NullPointerException at Java.CompileFile.doCompilation(CompileFile.java:48) at
I keep getting 21002 'java.lang.NullPointerException' errors from Apple when I try to test my
I'm getting a java.lang.NullPointerException right when the app launches and it shuts down. 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.