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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:44:00+00:00 2026-05-30T11:44:00+00:00

I am fetching Image and Text for GridView from a webservice, so its takes

  • 0

I am fetching Image and Text for GridView from a webservice, so its takes some time to display the GridView. I want to show a ProgressDialog till Grid gets fully loaded. What I have done till now is as below:

public class PCGridMain extends Activity
{
    WebService web = new WebService();
    private GridView gridView;
    ProgressDialog dialog;
    Bitmap icon;


    int i, total;
    URL url= null;
    List<GridItem> list;

    @Override
    public void onCreate(Bundle grid)
    {
        super.onCreate(grid);
        dialog = ProgressDialog.show(PCGridMain.this, "Loading...", "Loading App, Please wait.", true);
        DialogWork dWork = new DialogWork();
        dWork.execute();

        setContentView(R.layout.main);
        gridView = (GridView)findViewById(R.id.gridView1);

        web.WebService1();       
        total = web.totalService;        



        list = new ArrayList<GridItem>();

        for(i=0; i<total; i++)
            {
                    Log.v("Try Block", "See what we get:-");
                    try 
                    {
                        Log.v("GridMain", "try url"  + Integer.toString(i));
                        url = new URL(web.arr[i][2]);
                    }
                    catch (MalformedURLException e)
                    {   
                        Log.v("GridMain", "catch MalformedURLException" + Integer.toString(i));
                        e.printStackTrace();
                    }


                    try
                    {
                        Log.v("GridMain", "try BitmapFactory"  + Integer.toString(i));
                        icon = BitmapFactory.decodeStream(url.openConnection().getInputStream());
                    } 
                    catch (IOException e)
                    {   
                        Log.v("GridMain", "catch IOException"  + Integer.toString(i));
                        e.printStackTrace();
                    }

                    list.add(new GridItem(icon, web.arr[i][1]));                    // Adding Icon & LAbel              

            }

        gridView.setAdapter(new GridAdapter(this, list));
        gridView.setOnItemClickListener(Itemlistener);
    }



    private OnItemClickListener Itemlistener = new OnItemClickListener()
    {
        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position, long id)
        {
            ViewHolder holder = (ViewHolder)view.getTag();

            if(holder == null)
            {
                return;
            }
            Toast.makeText(PCGridMain.this, holder.label.getText(), Toast.LENGTH_SHORT).show();
                                                                                Log.v("GridMain", "Intent Creation");
            Intent intent = new Intent(view.getContext(), ShowService.class);   Log.v("GridMain", "Intent Created");
            intent.putExtra("ServiceId", web.arr[position][0]);                 Log.v("GridMain", "ValueAdded Sid");
            intent.putExtra("SName", holder.label.getText());                   Log.v("GridMain", "ValueAdded SName");

            startActivity(intent);          

        }
    };

    class DialogWork extends AsyncTask<URL, Integer, Long>
    {       
        protected Long doInBackground(URL... params) 
        {
            try
            {

            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        protected void onProgressUpdate(Integer... progress)
        {

        }

        protected void onPostExecute(Long result)
        {
            try
            {
                //setContentView(R.layout.main);
                //gridView.setAdapter(new GridAdapter(PCGridMain.this, list));              
                dialog.dismiss();                   
            }
            catch (Exception e)
            {
                e.printStackTrace();
                dialog.dismiss();
            }
        }

    }

Please tell me that what code has to be placed at what exact location, whenever I do some changes, it either shows no effect or App closes due to some issue.

Thanks,

Haps.

  • 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-30T11:44:01+00:00Added an answer on May 30, 2026 at 11:44 am

    Try to put all rendering part from server in doInBackground() and set the adapter in onPostExecute() . And even start the progressdialog in onPreExecute() in and dismiss it on onPostExecute() but not in onCreate(). I think it will solve ur problem….

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

Sidebar

Related Questions

When we need to download an image from some URL and show it on
I have a UIViewController and in that controller, i am fetching an image from
Hi i am getting the following exception while fetching the image from server. I
i am fetching around 1500 image url and want to store these images in
I am fetching number of images and text related to it from server Now
I am fetching image from server and save it on a NSMutableArray . The
I am fetching Uri of a image from gallery using Intent intent = new
I am using a image gallery in WordPress, images are fetching from database and
I am fetching friends of the logged in users on my website from facebook
I have looked around and found some code which so called chooses an image

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.