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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:14:34+00:00 2026-06-03T05:14:34+00:00

I have an Activity which loads a custom ImageView ( https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/example/touch/TouchImageView.java ). Inside onCreate,

  • 0

I have an Activity which loads a custom ImageView ( https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/example/touch/TouchImageView.java). Inside onCreate, I use setImageBitmap to display a huge image (4Mb…).

The problem is that this activity takes 4 seconds to show, but there is no blocking method which I could place in a AsyncTask. What I mean is that all my Activity code is executed, but the activity comes only when the image is loaded, and I don’t know when its finish.

What I want to do is showing a ProgressDialog while the Activity loads it, and displays it when it’s done.

How can I resolve this ? Here is some code.

Hope you’ll understand my problem, it’s pretty hard to explain. Thanks !

carte.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<loki.test.lokitest.affichage.TouchImageView 
    android:id="@+id/image"
    android:src="@drawable/loading"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

<Button 
    android:id="@+id/bouton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="@string/textBouton"/>


</RelativeLayout>

CarteActivity.java (The one who takes 4 seconds)

public class CarteActivity extends Activity implements OnClickListener{

private Group groupe;
private String android_id;
private ConnexionServeur serveur;
private TouchImageView vue;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.d("Loki","onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.carte);

    findViewById(R.id.bouton).setOnClickListener(this);

    vue = ((TouchImageView)findViewById(R.id.image));
    vue.setImageBitmap(Singleton.getInstance().getImage());

    groupe = Singleton.getInstance().getGroupe();
    android_id = Singleton.getInstance().getAndroid_id();
    serveur = Singleton.getInstance().getServeur();

    if(groupe != null)
            groupe.afficherGroupe(vue);

    }
}

EDIT :
The image is loaded with :

image = BitmapFactory.decodeResource(context.getResources(), R.drawable.myImage);

But I don’t think that this is this code which takes time, it is already done when i use setImageBitmap. I can’t figure out what takes so much time, but I wonder if it’s a metod I can access.

  • 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-03T05:14:35+00:00Added an answer on June 3, 2026 at 5:14 am
    • Make Layout xml top container (Top RelativeLayout) carry two elements

      1 Progress Bar – With Visibility Set to Visible. Make it large and in the center

      2 Relative Layout – Entire Content Body . Make it invisible first. It will be under progressbar and will be filling entire screen both height and width wise.

    • In oncreate setContentView and then starts a AysncTask that loads the imageview in doInBackground.In its postExecute make content body visible and progress bar invisible.
      Postexecute will get called only after when your loading is complete

    Hope this help and you can translate all this in code.

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

Sidebar

Related Questions

I have a doubt with media audio. My app haves an Activity which loads
Hi I have an application which after login, loads a main activity which contains
I have an activity which shows some List entries. When I click on a
I have an activity which needs to make two remote server calls. The first
I have an activity which uses two Loaders. Each of them returns different type
I have an activity which consists of a ListView . The problem is that
I have an Activity which uses a Fragment . I simply want to pass
I am having trouble with my activity management. So I have activity A which
I have created an activity which sends a number of notifications to status bar.
I have an Activity class which has an attribute that references an AsyncTask instance

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.