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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:29:44+00:00 2026-06-10T10:29:44+00:00

I am writing a drowing app. At the moment i have the next issue,

  • 0

I am writing a drowing app. At the moment i have the next issue, i get the next error when i am clicking on “redBtn” in “R.layout.activity_colors_prefs”.

   08-26 03:27:31.576: E/AndroidRuntime(706): FATAL EXCEPTION: main
    08-26 03:27:31.576: E/AndroidRuntime(706): java.lang.NullPointerException
    08-26 03:27:31.576: E/AndroidRuntime(706):  at com.example.drawview.ChooseColor$1.onClick(ChooseColor.java:43)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at android.view.View.performClick(View.java:4084)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at android.view.View$PerformClick.run(View.java:16966)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at android.os.Handler.handleCallback(Handler.java:615)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at android.os.Handler.dispatchMessage(Handler.java:92)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at android.os.Looper.loop(Looper.java:137)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at android.app.ActivityThread.main(ActivityThread.java:4745)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at java.lang.reflect.Method.invokeNative(Native Method)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at java.lang.reflect.Method.invoke(Method.java:511)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    08-26 03:27:31.576: E/AndroidRuntime(706):  at dalvik.system.NativeStart.main(Native Method)

According to debug mode the problem is in this command:

  • view_a.setdrawColor(Color.RED);

In the next class

public class ChooseColor extends Activity  {
    //View
    private DrawingView view_a;

    //Button
    Button redBtn;
    public int colorPref= Color.BLACK;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_colors_prefs);
        redBtn = (Button) findViewById(R.id.redColr);
        redBtn.setOnClickListener(myButtonListener);
        view_a=(DrawingView) findViewById(R.id.drawingView);
    }

    public int getColorPref() {
        return colorPref;
    }


    private OnClickListener myButtonListener = new OnClickListener() {

        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.redColr:
                Toast.makeText(getBaseContext(), "RED", Toast.LENGTH_SHORT).show();
                view_a.setdrawColor(Color.RED);     
                break;
            default:
                break;
            }

        }
    };

The method "setdrawColor" is the next:

public void setdrawColor(int color) 
{ 
   //create a copy of bitmap before changing the paint color 
     bitmap = Bitmap.createBitmap(bitmap); 
     canvas.setBitmap(bitmap); 
     paint.setColor(color); 
}

“setdrawColor” locatd in other activity, activity which called “DrawingView”.
“DrawingView” resposnible for drawing and extends View and doesnt extends Activity.

Can you please edvice what is the problem? what am i doing wrong?

  • 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-10T10:29:45+00:00Added an answer on June 10, 2026 at 10:29 am

    Do this before you call the method and report the result

    if (view_a != null) {
      view_a.setdrawColor(Color.RED);
    } else {
      Log.e("ChooseColor","view_a is null!");
    }
    

    I’m thinking view_a is never properly set. Can you confirm this?

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

Sidebar

Related Questions

Writing a test app to emulate PIO lines, I have a very simple Python/Tk
I am writing a simple drawing app to get an understanding of the HTML
I'm writing an iPad app and I have a custom view where I override
I'm writing a biorhythm app. To test it i have a form with a
I am writing a small app that at the moment generates a random map
I'm writing a drawing application that includes shapes that can have children. When I
Writing a python program, and I came up with this error while using the
I'm writing android app, which drawing 4 graphs in 1 plot. Graph data is
I am writing an app that needs to capture a users signature in a
I'm writing a iPhone app that needs to render i18n text that includes diacriticals

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.