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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:26:46+00:00 2026-05-27T07:26:46+00:00

I have a about screen that has some buttons, but I keep getting NullPointerException

  • 0

I have a about screen that has some buttons, but I keep getting NullPointerException in the first setOnClickListener line,what’s the problem?

about.java

public class About extends Activity{

    private Button backbutton;
    private Button likebutton;
    private Button faq;
    private Button update;
    private Button feedback;
    private Button rate;
    private Button help;

    private String faqpath ="http://appkon.com/hdtvs/faq.html";
    private String faqname ="常见问题";
    private String feedbackpath="http://appkon.com/hdtvs/feedback.html" ;
    private String feedbackname="反馈问题" ;
    private String ratename="评价APP" ;
    private String ratepath="http://appkon.com/hdtvs/rate.html" ;
    private String updatepath="http://appkon.com/hdtvs/update.html" ;
    private String updatename="检查更新" ;

    private String wentiname ="";
    private String wentipath ="";
    private String gengxinname ="";
    private String gengxinpath ="";
    private String pingjianame ="";
    private String pingjiapath ="";
    private String changjianpath ="";
    private String changjianname ="";



    @Override    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        backbutton=(Button) findViewById(R.id.back);
        likebutton=(Button) findViewById(R.id.share);
        faq =(Button)findViewById(R.id.faq);
        update =(Button)findViewById(R.id.update);
        feedback =(Button)findViewById(R.id.feedback);
        rate =(Button)findViewById(R.id.rate);
        help =(Button)findViewById(R.id.child);

        try{


        backbutton.setOnClickListener(new Button.OnClickListener()
        {
          public void onClick(View v)
          {
            Intent intent = new Intent();
            intent.setClass(About.this, HDtvs.class);
            startActivity(intent);
            About.this.finish();

          }
        });

        likebutton.setOnClickListener(new Button.OnClickListener()
        {
          public void onClick(View v)
          {
            Intent intent = new Intent();
            intent.setClass(About.this, Renrenframe.class);
            startActivity(intent);
            About.this.finish();

          }
        });

        faq.setOnClickListener(new Button.OnClickListener()
        {
          public void onClick(View v)
          {
            Intent intent = new Intent();
            intent.setClass(About.this, Aboutframe.class);
            Bundle bundle = new Bundle();
            bundle.putString("changjianpath",faqpath);
            bundle.putString("changjianname",faqname);
            intent.putExtras(bundle);
            startActivity(intent);
            About.this.finish();

          }
        });

        feedback.setOnClickListener(new Button.OnClickListener()
        {
          public void onClick(View v)
          {
            Intent intent = new Intent();
            intent.setClass(About.this, Aboutframe.class);
            Bundle bundle = new Bundle();
            bundle.putString("wentipath",feedbackpath);
            bundle.putString("wentiname",feedbackname);
            intent.putExtras(bundle);
            startActivity(intent);
            About.this.finish();

          }
        });

        rate.setOnClickListener(new Button.OnClickListener()
        {
          public void onClick(View v)
          {
            Intent intent = new Intent();
            intent.setClass(About.this, Aboutframe.class);
            Bundle bundle = new Bundle();
            bundle.putString("pingjiapath",ratepath);
            bundle.putString("pingjianame",ratename);
            intent.putExtras(bundle);
            startActivity(intent);
            About.this.finish();

          }
        });

        update.setOnClickListener(new Button.OnClickListener()
        {
          public void onClick(View v)
          {
            Intent intent = new Intent();
            intent.setClass(About.this, Aboutframe.class);
            Bundle bundle = new Bundle();
            bundle.putString("gengxinpath",updatepath);
            bundle.putString("gengxinname",updatename);
            intent.putExtras(bundle);
            startActivity(intent);
            About.this.finish();

          }
        });

        help.setOnClickListener(new Button.OnClickListener()
        {
          public void onClick(View v)
          {
            Intent intent = new Intent();
            intent.setClass(About.this, WapsList.class);
            startActivity(intent);
            About.this.finish();

          }
        });
        }catch (Exception e)
        { 
            e.printStackTrace();
        }
}
}

about.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
    android:gravity="center|top"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/main_background_repeat"
>

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="45dip"
    android:id="@+id/header"
    android:background="@drawable/header"
    >

<Button android:id="@+id/back" 
    android:textSize="14.0sp" 
    android:textColor="#ffe1ebef" 
    android:gravity="center"    
    android:background="@drawable/button_back" 
    android:layout_width="54.0dip" 
    android:layout_height="33.0dip" 
    android:layout_marginLeft="10.0dip" 
    android:text="@string/back" 
    android:layout_alignParentLeft="true" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" />

    <TextView 
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:textColor="#FFFFFF"
            android:textSize="18.0sp"
    android:layout_marginTop="8dip"
    android:text="@string/about"/>


<Button android:id="@+id/share" 
    android:textSize="14.0sp" 
    android:textColor="#ffe1ebef" 
    android:gravity="center"    
    android:background="@drawable/share" 
    android:layout_width="54.0dip" 
    android:layout_height="33.0dip" 
    android:layout_marginRight="10.0dip" 
    android:text="@string/share" 
    android:layout_alignParentRight="true"
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:layout_marginTop="10dip"/>

    </RelativeLayout>


    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/function"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
      android:orientation="vertical"
    android:gravity="center|top"
    android:layout_marginTop="20dip">

   <TextView android:id="@+id/funcdesc"
    android:layout_width="280dip"
    android:layout_height="wrap_content"
    android:text="@string/funcdesc"
    android:gravity="center" />


   <Button android:id="@+id/feedback"
     android:textColor="#6f789b"
     android:textSize="16.0sp"
     android:gravity="center"   
     android:background="@drawable/button" 
     android:layout_width="185.0dip" 
     android:layout_height="44.0dip" 
     android:layout_marginRight="10.0dip" 
     android:text="@string/feedback" 
     android:layout_alignParentRight="true"
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:layout_marginTop="10dip"/>

   <Button android:id="@+id/rate"
     android:textColor="#6f789b"
     android:textSize="16.0sp"
     android:gravity="center"   
     android:background="@drawable/button" 
     android:layout_width="185.0dip" 
     android:layout_height="44.0dip" 
     android:layout_marginRight="10.0dip" 
     android:text="@string/rate" 
     android:layout_alignParentRight="true"
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:layout_marginTop="10dip"/>

   <Button android:id="@+id/faq"
     android:textColor="#6f789b"
     android:textSize="16.0sp"
     android:gravity="center"   
     android:background="@drawable/button" 
     android:layout_width="185.0dip" 
     android:layout_height="44.0dip" 
     android:layout_marginRight="10.0dip" 
     android:text="@string/faq" 
     android:layout_alignParentRight="true"
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:layout_marginTop="10dip"/>

   <Button android:id="@+id/update"
     android:textColor="#6f789b"
     android:textSize="16.0sp"
     android:gravity="center"   
     android:background="@drawable/button" 
     android:layout_width="185.0dip" 
     android:layout_height="44.0dip" 
     android:layout_marginRight="10.0dip" 
     android:text="@string/update" 
     android:layout_alignParentRight="true"
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true"
     android:layout_marginTop="10dip" />

     </LinearLayout>


    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/donation"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
      android:orientation="vertical"
    android:gravity="center|top"
    android:layout_marginTop="20dip">

    <TextView android:id="@+id/funcdesc"
    android:layout_width="280dip"
    android:layout_height="wrap_content"
    android:text="@string/helpdesc"
    android:gravity="center" />

     <Button android:id="@+id/child"
     android:textColor="#6f789b"
     android:textSize="16.0sp"
     android:gravity="center"   
     android:background="@drawable/button" 
     android:layout_width="185.0dip" 
     android:layout_height="44.0dip" 
     android:layout_marginRight="10.0dip" 
     android:text="@string/child" 
     android:layout_alignParentRight="true"
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true"
     android:layout_marginTop="10dip" />

     </LinearLayout>


</LinearLayout>

This is my error track

12-05 13:36:27.466: WARN/System.err(308): java.lang.NullPointerException
12-05 13:36:27.476: WARN/System.err(308):     at com.appkon.hdtvs.About.onCreate(About.java:59)
12-05 13:36:27.486: WARN/System.err(308):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-05 13:36:27.506: WARN/System.err(308):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
12-05 13:36:27.506: WARN/System.err(308):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
12-05 13:36:27.526: WARN/System.err(308):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
12-05 13:36:27.537: WARN/System.err(308):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
12-05 13:36:27.546: WARN/System.err(308):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 13:36:27.556: WARN/System.err(308):     at android.os.Looper.loop(Looper.java:123)
12-05 13:36:27.576: WARN/System.err(308):     at android.app.ActivityThread.main(ActivityThread.java:4363)
12-05 13:36:27.586: WARN/System.err(308):     at java.lang.reflect.Method.invokeNative(Native Method)
12-05 13:36:27.596: WARN/System.err(308):     at java.lang.reflect.Method.invoke(Method.java:521)
12-05 13:36:27.596: WARN/System.err(308):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-05 13:36:27.607: WARN/System.err(308):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-05 13:36:27.616: WARN/System.err(308):     at dalvik.system.NativeStart.main(Native Method)

Your post does not have much context to explain the code sections; please explain your scenario more clearly.

  • 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-27T07:26:47+00:00Added an answer on May 27, 2026 at 7:26 am

    Looks like you’re setting the contentView to R.layout.main, but the file is named about.xml. If main.xml does not contain a widget with the id back then it will return null from findViewById()

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

Sidebar

Related Questions

Screen is amazing, of course, but I don't want to have to think about
I have about 10million values that I need to put in some type of
I have a simple Screen class in C# that has a bunch of events
I've been working on an iPad application that has about 15 view controllers. Some
I have a UIView that will eventually contain about 2 screens worth of information.
I have been thinking quite a bit here lately about screen scraping and what
I have about 200 Excel files that are in standard Excel 2003 format. I
I have about 10 drop down list controls that get populated. Instead of copying/pasting
I have about 4-5 years of background in programming some in C# and some
I'd started for about a mouth and I have some problems now :( 1.

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.