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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:27:37+00:00 2026-05-26T05:27:37+00:00

I have a class that extends Activity and within it got a private class

  • 0

I have a class that extends Activity and within it got a private class that extends View which i calling it to load the images. However, i wasn’t whether i should use AsyncTask, Handler or other ways to perform the loading of images on the background and showing the progressBar at the same time while loading. For AsyncTask, the task instance must be created on the UI thread (which i presume is in the Activity class). But all the function is in the View class and have trouble using AsyncTask. Is using Handler a good choice?

public class LargeImageScroller extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            setContentView(new SampleView(this));
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {...}

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {...}

    private static class SampleView extends View {

        public SampleView(Context context) {...}
        public boolean onTouchEvent(MotionEvent event) {...}
        protected void onDraw(Canvas canvas) {...}
        private boolean createMap(Context context) {...}
}

This is the rough skeleton of the program. createMap() is the function where i load images into a canvas so as to display the images. But if i declare a class that extends AsyncTask, the task instance can only be created in the onCreate() and not anywhere else so i have problem calling the createMap() to load the images. I was thinking of using Handler so as to load the images on a separate thread from the main thread. Can anyone tell me is there a better way of doing things?

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

    There’s a really good post on multithreading in Android here. Should give you a few hints on what to do.

    http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html

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

Sidebar

Related Questions

I have a class that extends View. I override the onDraw method and allow
I have a custom-made view that extends the View class. I would like 2
I have an Activity calling a Service defined in IDownloaderService.aidl: public class Downloader extends
I have a jar that consists of a class that extends Activity and performs
I am having a class that extends View. I have another class that extends
Have following setup: MainActivity class - extends activity MyLayout class - extends View Prefs
I have a class called FileGeneration that extends Activity In FileGeneration I have a
I have a async task called within an activity: public class DownloadFile extends AsyncTask<String,
I have an Android Activity that uses a class that I developed that extends
I have a class that extends android.app.Dialog, the layout is done in an xml

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.