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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:52:31+00:00 2026-06-18T07:52:31+00:00

I am now making a drawing app where user can import pictures from gallery

  • 0

I am now making a drawing app where user can import pictures from gallery and further draw on it. Pictures can be loaded successfully and things could be drawn successfully, but i would like to further modify because when the imported files dimension is greater than the screen size, it will only show part of the image.

Hence i load the screen dimension and the importing file demension and if certain conditions, it will popup the alertdialog such that the user can either choose to stetch or to import that pic by filling up the maximum width or height, keeping the width:height scale.

For loading the picture, it is in ActivityA calling a method in ActivityB (name as DrawView).

Question:

The alertdialog underlines an error The constructor AlertDialog.Builder(DrawView) is undefined at the phrase

new AlertDialog.Builder(this);  

I have tried modified the above as

new AlertDialog.Builder(DrawView.this);  

but still fails. How could this be modified? Many thanks!!!

Coding:

   public void load_pic(String picturePath) // load a picture from gallery
   {   
       // get screen dimension first
       WindowManager wm = (WindowManager) context_new.getSystemService(Context.WINDOW_SERVICE);
       Display display = wm.getDefaultDisplay();
       int screenWidth = display.getWidth();
       int screenHeight = display.getHeight(); 

       Options op = new Options();
       op.inJustDecodeBounds = true;
       Bitmap pic_to_be_imported = BitmapFactory.decodeFile(picturePath, op);
       int x_pic_to_be_imported = op.outWidth;
       int y_pic_to_be_imported = op.outHeight;

       if ((x_pic_to_be_imported > screenWidth) || (y_pic_to_be_imported > screenHeight))
       {
              TextView myView2 = new TextView(context_new.getApplicationContext()); 
              myView2.setText(R.string.message_load_pic);
              myView2.setTextSize(15); 

              AlertDialog.Builder onBackBuilder = new AlertDialog.Builder(DoodleView.this);         
              onBackBuilder.setTitle(R.string.menuitem_on_load_pic);
              onBackBuilder.setView(myView2); 

              onBackBuilder.setCancelable(true);                   

              onBackBuilder.setPositiveButton(R.string.buttontext_create_load_pic_extend, new DialogInterface.OnClickListener() 
              {
                 public void onClick(DialogInterface dialog, int id) 
                    {   
                       //code
                    }            
              });

              onBackBuilder.setNegativeButton(R.string.buttontext_create_load_pic_keep_scale, new DialogInterface.OnClickListener() 
              {
                  public void onClick(DialogInterface dialog, int id) 
                    {                       
              bitmap = (BitmapFactory.decodeFile(picturePath)).copy(Bitmap.Config.ARGB_8888, true)
                          .createScaledBitmap(bitmap, screenWidth, screenHeight, true);
              bitmapCanvas = new Canvas(bitmap);
                    }             
              });

              AlertDialog alert = onBackBuilder.create();
              alert.show();            
       }

          // further codes
   }
  • 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-18T07:52:31+00:00Added an answer on June 18, 2026 at 7:52 am

    pass Activity context for creating AlertDialog instead of non Activity Class as:

    AlertDialog.Builder onBackBuilder = new AlertDialog.Builder(context_new);
    

    where context_new is Activity context which you are passing to DoodleView at the time of object creation in Activity

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

Sidebar

Related Questions

So, I'm making a relatively trivial HTML5 Canvas drawing web app. Basically, you can
I am making a desktop app with MonoMac that relies on system.drawing. This works
I am making a drawing program in python with pygame right now. The interface
i am making a time table app. i am now testing how does the
I'm now making unit-tests for already existing code. I faced the next problem: After
I'm modelling MySQL database for an website. I'm now making 'people' table, and deciding
I have some data in db,now i m making them to display in the
My project uses several dll files with activex controls. Now I am making a
I've got legacy code sample which uses JFreeChart and XYPlot. Now i'm making i18n
now, I'm making a chatbox. This is the code of the page were you

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.