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

  • Home
  • SEARCH
  • 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 3403868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:18:47+00:00 2026-05-18T05:18:47+00:00

I have a null pointer on a button that I need to take me

  • 0

I have a null pointer on a button that I need to take me to a new layout when pushed. I have the code set as:

((Button) findViewById(R.id.analyzee)).setOnClickListener(btnClick);

inside a method that uses conditional statements.

It is a basic face detect app. If faces are not found, I do this:

if (facesFound < 1) {
                mFlipper.setDisplayedChild(2);
                mTheMessage = (TextView) findViewById(R.id.falsemessage);
                mThePicture = (ImageView) findViewById(R.id.false_view);
                mTheMessage.setText(R.string.noFaceOne);
                mThePicture.setImageBitmap(bitmap565);
                return; 

if faces are found, I draw a box on the face, and do this:

mFlipper.setDisplayedChild(1);
            mTheMessage.setText(R.string.noFaceFive);
            mThePicture.setImageBitmap(bitmap565);

My issue lies here though, I use this method to run when buttons are clocked:

private final View.OnClickListener btnClick = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.scan_box:
                openCamera();
                break;

            case R.id.crop_face:
                final ProgressDialog dialog = ProgressDialog.show(Main.this, "",
                        "Cropping photo", true);
                dialog.show();

                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        dialog.dismiss();
                    }
                }, 3000);

                cropFace();
                break;

So, my issue lies in this:

In one of my layouts in the flipper, the button that rests on the layout will need to give the user the option to snap a new picture if there are no faces found. The other layout will need the button (upon click) to have the faces cropped and the results to be sent to another layout.

The issue I am facing is where the code:

((Button) findViewById(R.id.crop_face)).setOnClickListener(btnClick);

needs to be placed in order for the program to release the button has been clicked, it calls the case in my switch statement, and runs the crop face_method.

I try putting it in the if statement where I set the image View and text View, but I get a null pointer on that line I am declaring my button on.

The buttons I have on my main menu work fine, as they are in my onCreate method, but I don’t know where to play this button command, and also where I need to place my reopen Camera command.

Thanks!

  • 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-18T05:18:47+00:00Added an answer on May 18, 2026 at 5:18 am

    I simply was using the wrong button ID…sorry for the confusion =x

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

Sidebar

Related Questions

I have a strange problem regarding null pointer exception. I'm posting the problematic code
I have such code to read a text file using BufferedReader : BufferedReader reader=null;
I'm working on a JSP page, but I'm running into a null pointer at
Ok so i have 5 arrays all with 5 elements in them in my
OK, well I've been working on a simple app that allows users to save
I have a create method as shown below, in which I want to (if
i have done up a method to return a string values of a textfile
I have an Android application which, among other things, also publishes updates on Facebook.
I'm trying to implement a Java/C++ binding for a sound streaming class. To keep
@Jonah pointed me to the following explanation he has provided: Question on View Controller's

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.