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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:31:29+00:00 2026-05-28T05:31:29+00:00

I am getting a nullpointerexception error on this line btn10.setOnClickListener(this); this is the entire

  • 0

I am getting a nullpointerexception error on this line

btn10.setOnClickListener(this);

this is the entire java

package com.james.helloandroid2;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;


//** activity 
public class HelloAndroid2 extends Activity implements OnClickListener,        ColorPickerDialog.OnColorChangedListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pokertable);



    //** imagebuttons
    ImageView button10 = (ImageView) findViewById(R.id.button10);
    button10.setOnClickListener(this);


    View btn9 = (View) findViewById(R.id.button9);
    //btn9.setOnClickListener(this); 
    View btn8 = (View) findViewById(R.id.button8);
    //btn8.setOnClickListener(this);
    View btn7 = (View) findViewById(R.id.button7);
    //btn7.setOnClickListener(this);
    View btn6 = (View) findViewById(R.id.button6);
    //btn6.setOnClickListener(this);
    View btn5 = (View) findViewById(R.id.button5);
    //btn5.setOnClickListener(this);
    View btn4 = (View) findViewById(R.id.button4);
    //btn4.setOnClickListener(this); 
    View btn3 = (View) findViewById(R.id.button3);
    //btn3.setOnClickListener(this); 
    View btn2 = (View) findViewById(R.id.button2);
    //btn2.setOnClickListener(this); 
    View btn1 = (View) findViewById(R.id.button1);        
    //btn1.setOnClickListener(this); {
}
//** not in use yet.
public void colorChanged(int color) {
    // TODO Auto-generated method stub

}

public void onClick(View v) {
    // TODO Auto-generated method stub
    ColorPickerDialog dialog = new ColorPickerDialog(this, null, 0);
    dialog.show();

}

}

im not sure why if anyone could help.

also just a ps. i have certain things forward slashed so they are exempt in my code.. more of notes for me or code im waiting to actually use.

<?xml version="1.0" encoding="utf-8"?>
   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="clip_horizontal"
    android:layout_weight="0.20"
    android:background="@drawable/tablebackground"
    android:gravity="top" >


    <ImageView
        android:id="@+id/button8"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="@string/seat5" 
        android:src="@drawable/shapebutton5" />



    <ImageView
        android:id="@+id/button10"
        android:layout_width="55dp"
        android:layout_height="40dp"
        android:layout_marginTop="5dp"
        android:layout_centerHorizontal="true" 
        android:src="@drawable/shapebutton10" />



    <ImageView
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginLeft="31dp"
        android:layout_toRightOf="@+id/button10"
        android:onClick="onMyButtonClick"
        android:src="@drawable/shapebutton1" />



   <ImageView
        android:id="@+id/button7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginRight="30dp"
        android:layout_toLeftOf="@+id/button10"
        android:src="@drawable/shapebutton9" />



    <ImageView
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button7"
        android:layout_alignParentBottom="true"
        android:src="@drawable/shapebutton6" />



   <ImageView
        android:id="@+id/button6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button3"
        android:layout_alignParentBottom="true"
        android:src="@drawable/shapebutton4" />



    <ImageView
        android:id="@+id/button5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button6"
        android:layout_alignParentRight="true"
        android:layout_marginRight="25dp"
        android:src="@drawable/shapebutton3" />



    <ImageView
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button5"
        android:layout_below="@+id/button3"
        android:src="@drawable/shapebutton2" />



   <ImageView
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button5"
        android:layout_alignBottom="@+id/button5"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="19dp"
        android:src="@drawable/shapebutton7" />



   <ImageView
        android:id="@+id/button9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button4"
        android:layout_alignBottom="@+id/button4"
        android:layout_alignLeft="@+id/button1"
        android:src="@drawable/shapebutton8" />

</RelativeLayout>



01-18 23:09:31.842: D/AndroidRuntime(810): Shutting down VM
01-18 23:09:31.842: W/dalvikvm(810): threadid=1: thread exiting with uncaught exception     (group=0x40015560)
01-18 23:09:31.852: E/AndroidRuntime(810): FATAL EXCEPTION: main
01-18 23:09:31.852: E/AndroidRuntime(810): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.james.helloandroid2/com.james.helloandroid2.HelloAndroid2}:      java.lang.NullPointerException
01-18 23:09:31.852: E/AndroidRuntime(810):  at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-18 23:09:31.852: E/AndroidRuntime(810):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-18 23:09:31.852: E/AndroidRuntime(810):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-18 23:09:31.852: E/AndroidRuntime(810):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
 01-18 23:09:31.852: E/AndroidRuntime(810):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-18 23:09:31.852: E/AndroidRuntime(810):  at android.os.Looper.loop(Looper.java:123)
01-18 23:09:31.852: E/AndroidRuntime(810):  at android.app.ActivityThread.main(ActivityThread.java:3683)
01-18 23:09:31.852: E/AndroidRuntime(810):  at java.lang.reflect.Method.invokeNative(Native Method)
01-18 23:09:31.852: E/AndroidRuntime(810):  at java.lang.reflect.Method.invoke(Method.java:507)
01-18 23:09:31.852: E/AndroidRuntime(810):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-18 23:09:31.852: E/AndroidRuntime(810):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-18 23:09:31.852: E/AndroidRuntime(810):  at dalvik.system.NativeStart.main(Native Method)
01-18 23:09:31.852: E/AndroidRuntime(810): Caused by: java.lang.NullPointerException
01-18 23:09:31.852: E/AndroidRuntime(810):  at com.james.helloandroid2.HelloAndroid2.onCreate(HelloAndroid2.java:23)
01-18 23:09:31.852: E/AndroidRuntime(810):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
 01-18 23:09:31.852: E/AndroidRuntime(810):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-18 23:09:31.852: E/AndroidRuntime(810):  ... 11 more
  • 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-28T05:31:30+00:00Added an answer on May 28, 2026 at 5:31 am

    Are you defining your ImageViews in R.layout.pokertable? Activity.findViewById isn’t magical, it simply performs a recursive search down the view hierarchy attached to an activity’s current window. If you haven’t attached these views by using setContentView yet, findViewById will return null because there were no matching views present to find.

    Maybe posting your Activity’s XML layout file will help us pin-point the problem.

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

Sidebar

Related Questions

Exception in thread main java.lang.NullPointerException at com.hibernate.UserDAO.findAll(UserDAO.java:154) at test.main(test.java:12) I am getting this error
I keep getting this error 07-14 23:53:03.653: ERROR/AndroidRuntime(14995): java.lang.NullPointerException 07-14 23:53:03.653: ERROR/AndroidRuntime(14995): at com.fttech.organizeit.meeting_list$meetingHolder.populateFrom(meeting_list.java:110)
I keep getting this java.lang.NullPointerException on the line where mLoginButton's onClickListener is initiated. I
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.
I am getting a java.lang.NullPointerException error on line 41 (setText) when I execute the
I am getting this error when i use a string array java.lang.NullPointerException The code
package com.org.myOxygen.activities; import java.util.Stack; import android.app.Activity; import android.app.ActivityGroup; import android.app.LocalActivityManager; import android.content.Intent; import android.os.Bundle;
We're getting this error java.lang.NullPointerException at java.util.ArrayList.<init>(Unknown Source) at de.mystuff.ExtendedArrayList.<init>(ExtendedArrayList.java:38) where ExtendedArrayList:38 is new
Getting this error: java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:200) at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
I'm getting an error of a NullPointerException and it is referencing the line Camera.Parameters:

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.