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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:51:05+00:00 2026-05-28T16:51:05+00:00

My code as follows: public class wall extends Activity { GridView webgridview; Button web;

  • 0

My code as follows:

public class wall extends Activity {
GridView webgridview;
Button web;

ProgressDialog pd;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.wall);

pd = ProgressDialog.show(wall.this,"Loading", "Please Wait...",true);
                new Thread() {
                    public void run() {
                    try {
webgridview.setAdapter(new WebImageAdapter(wall.this));
}catch(Exception e)
{
}
handler.sendEmptyMessage(0);
pd.dismiss();
}
}.start();
private Handler handler = new Handler() {
    public void handleMessage(Message msg) {
        Toast.makeText(wall.this, "finished", 1).show();
    }
};

And my adapter class as follows. I code progress dialog in above class only.

public class WebImageAdapter extends BaseAdapter {
private Context mContext;
public static String[] myRemoteImages = {
    "http://www.evergreenhits.com/ad/wallpapers/3d_1.jpg",
    "http://www.evergreenhits.com/ad/wallpapers/3d_2.jpg",
    "http://www.evergreenhits.com/ad/wallpapers/3d_3.jpg",
    "http://www.evergreenhits.com/ad/wallpapers/3d_4.jpg",
    "http://www.evergreenhits.com/ad/wallpapers/3d_5.jpg"
        };

public WebImageAdapter(Context c) {
    mContext = c;
}

public int getCount() {
    //return animals.length;
     return this.myRemoteImages.length;

}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

// create a new ImageView for each item referenced by the Adapter
public ImageView getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    imageView = new ImageView(mContext);
    if (convertView == null) {

        imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

        imageView.setPadding(8, 8, 8, 8);
  } else {
        imageView = (ImageView) convertView;
    }

try { 
URL aURL = new URL(myRemoteImages[position]); 
URLConnection conn = aURL.openConnection(); 
conn.connect(); 
InputStream is = conn.getInputStream(); 
BufferedInputStream bis = new BufferedInputStream(is); 
Drawable d=Drawable.createFromStream(bis, "src Name");

bis.close(); 
is.close(); 
imageView.setImageDrawable(d); 
} catch (IOException e) { 
Log.e("DEBUGTAG", "Remote Image Exception", e); 
} 

imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); 
imageView.setLayoutParams(new GridView.LayoutParams(150, 150)); 
    return imageView;
}

The progress Dialog doesnt work properly. It shows and suddenly gone before the images loaded in gridview. Please help me asap.

  • 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-28T16:51:06+00:00Added an answer on May 28, 2026 at 4:51 pm

    Use AsyncTask:

    calling:

    dialog=ProgressDialog.show(wall.this,"Loading", "Please Wait...",true);
            doback dob=new doback();
            dob.execute();
    

    Class

    class doback extends AsyncTask<URL, Integer, Long>
        {
    
            @Override
            protected Long doInBackground(URL... arg0) 
            {
                try
                {
                            //getImagepaths from Server
                }
                catch(Exception e)
                {
                    
                }
                return null;
            }
            protected void onProgressUpdate(Integer... progress) 
            {
                
            }
            protected void onPostExecute(Long result) 
            {
                try
                {
                    webgridview.setAdapter(new WebImageAdapter(wall.this));
                    
                    dialog.dismiss();
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                    dialog.dismiss();
                }
            }
        }
    

    Adapter Code is some like this:

    class WebImageAdapter extends BaseAdapter{
    
    //      @Override
            public int getCount() {
        
            return names.length;
            }
    
    //      @Override
            public Object getItem(int position) {
            
            return null;
            }
    
    //      @Override
            public long getItemId(int position) {
            
            return 0;
            }
    
    //      @Override
            public View getView(int pos, View convertView, ViewGroup parent) {
            View row=getLayoutInflater().inflate(R.layout.nameitem,null);
            ImageView image=(ImageView)row.findViewById(R.id.image);
    
            image.setImageBitmap(convertImage(myRemoteImages[position]))// convertImage is to convert url to bitmap
            return row;
            }
                
            }
    

    Edit – From the Android Developer Documentation:ProgressDialog

    This class was deprecated in API level 26.

    ProgressDialog is a modal
    dialog, which prevents the user from interacting with the app. Instead
    of using this class, you should use a progress indicator like
    ProgressBar, which can be embedded in your app’s UI. Alternatively,
    you can use a notification to inform the user of the task’s progress.

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

Sidebar

Related Questions

I have a piece of code like follows public class Test{ public static void
My sample code is as follows: public class ExceptionsDemo { public static void main(String[]
Ok, here is the code and then the discussion follows: public class FlatArrayList {
The code under test follows. view.QueryResultsGrid is a System.Windows.Forms.DataGridView object: public void SelectCheckedChanged(object sender,
I have a code snippet as public class ThreadStates { private static Thread t1
I have an Address object defined simply as follows: public class Address { public
I have the following code(simplified). public class OrderProcessor { public virtual string PlaceOrder(string test)
I have an exception class as follows: #include <exception> struct InvalidPathException : public std::exception
I have an ObservableCollection of objects as follows: public class UserDataViewModel { private ObservableCollection<CategoryItem>
I have a custom initializer setup as follows: public class PromptIfChangesNeededDBInitializer : IDatabaseInitializer<MeyerREContext> {

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.