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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:50:18+00:00 2026-05-27T06:50:18+00:00

I am drawing a bitmap in my onDraw and want to be able to

  • 0

I am drawing a bitmap in my onDraw and want to be able to change that image when a user clicks on a certain part of the screen. I display the image like this…

protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.drawColor(Color.WHITE);
    canvas.drawBitmap(mallMap, 0, 0, null);
    canvas.drawLines(pts, paint);}

then in my onTouch method I’d like to be able to redraw a different bitmap

public boolean onTouchEvent(MotionEvent event) {
    final int action = event.getAction();
    final int x = (int) event.getX();
    final int y = (int) event.getY();

    if (action == MotionEvent.ACTION_DOWN) {
    Canvas.drawBitmap(lowerLeft, 0, 0, null);
    return false;}

is something like this possible? I need to stick with a canvas and am not sure how I would got about doing this.

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-27T06:50:18+00:00Added an answer on May 27, 2026 at 6:50 am

    You can do this by changing the value of mallMap to a new Bitmap in the onTouchEvent and then calling invalidate() on the view to cause the onDraw to be run again. You should not have to reference the canvas outside of the onDraw using this method.

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

Sidebar

Related Questions

I have an object that contains: the image itself (type: {System.Drawing.Bitmap}) image type (type:
Can I combine code that uses System.Drawing.Bitmap together with other code in a program
How do you convert a System.Drawing.Bitmap image to another type of image? I tried
I want to create a PNG file from a System.Drawing.Bitmap with the colours defined
I need to change the DPI of the System.Drawing.Bitmap object from the default value
I m drawing in a bitmap like.. bitmap[i] = new Bitmap(60, 60); Graphics g
I have created a custom view and drawing a bitmap image. How can i
I'm trying to implement a function that takes a System.Drawing.Bitmap object and renders it
When I try to save an image using either System.Drawing.Image.Save(String) or System.Drawing.Bitmap.Save(String) an exception
I have around 10 System.Drawing.Bitmap elements, which I want to dump to PDF. When

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.