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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:28:24+00:00 2026-05-23T01:28:24+00:00

Sorry about the in-concise title. I have an Android app in which I draw

  • 0

Sorry about the in-concise title. I have an Android app in which I draw in a class that is run on a CanvasThread, to be kept away from the main GUI-thread.
But now when I want to draw rectangles based on data from a query to the DataHelper-class.
When I want to instantiate the DataHelper with DataHelper dh = new DataHelper(this); i get the complaint that I need another constructor in DataHelper, that takes PanelChart as argument instead of Context. Why is this?

This is my PanelChart-class:

public class PanelChart extends SurfaceView implements SurfaceHolder.Callback {
private CanvasThread canvasthread ;
private SurfaceView sf;
private DataHelper dh ;

public PanelChart(Context context, AttributeSet attrs) {
    super(context, attrs);


getHolder().addCallback(this);
canvasthread = new CanvasThread(getHolder(), this);
sf = (SurfaceView) findViewById(R.id.SurfaceView01);
setFocusable(true);



  //getData(dh);

}

The getData(dh); is from where I want to call the method which calls DataHelper and retrieves the info needed to draw.

Should I make another constructor in DataHelper? Should I do the query in another class and send it to my PanelChart class?

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-23T01:28:24+00:00Added an answer on May 23, 2026 at 1:28 am

    I think you should use context parameter from PanelChart constructor, that’s the context of Activity, in which you create PanelChart:

    public class PanelChart extends SurfaceView implements SurfaceHolder.Callback {
    private CanvasThread canvasthread ;
    private SurfaceView sf;
    private DataHelper dh ;
    
    public PanelChart(Context context, AttributeSet attrs) {
        super(context, attrs);
    
    DataHelper dh = new DataHelper(context);
    getHolder().addCallback(this);
    canvasthread = new CanvasThread(getHolder(), this);
    sf = (SurfaceView) findViewById(R.id.SurfaceView01);
    setFocusable(true);
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry about the terrible title. I have a signed assembly 'Signed.dll' that is a
Sorry about that confusing title :) I have a resource, ComatosePage (used in the
Sorry the title isn't more help. I have a database of media-file URLs that
Sorry about the title. That was the best I could come up with. Anyways,
Sorry about the weird title... all will be explained. Basically I have an array/dictionary
Sorry about the rubbish question title. I have a table SET_DEFINITIONS like this: SETKEY
Sorry about the vague question title, but I have these typedefs here: typedef std::list<AnimationKeyframe>
I really didnt know what to put to the title so sorry about that.
Sorry about the confusing title. Are there any web IDEs available that can be
Sorry about the weird question title, but I don't really know what to call

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.