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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:00:44+00:00 2026-06-01T13:00:44+00:00

I am using a Gallery and I bind a ImageView , ImageButton and a

  • 0

I am using a Gallery and I bind a ImageView, ImageButton and a ProcessBar to it. There are more than 50 images in the gallery and in the getView() method when took the ViewGroup.getChildCount(). It returns only an int value of 3.

Why the ViewGroup.getChildCount() returns 3 even if I scroll all the images are there.

So I am getting error in the method :

ViewGroup.getChildAt(position).findViewById(R.id.progressbar_Horizontal).setVisibility(View.VISIBLE);

Main Activity

public class SliderActivity extends Activity {  

     private Integer[] mImageIds = {
                R.drawable.sample_1,
                R.drawable.sample_2,
                R.drawable.sample_3,
                R.drawable.sample_4,
                R.drawable.sample_5,
                R.drawable.sample_6,
                R.drawable.sample_7
        };
    /** Called when the activity is first created. */

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);               

        Gallery gallery = (Gallery) findViewById(R.id.gallery);
        gallery.setAdapter(new ImageAdapter(this,mImageIds));      

    }


}

ImageAdapter Class :

public class ImageAdapter extends BaseAdapter {

    private int mGalleryItemBackground;
    private Activity mContext;
    private Integer[] Images;
    private int[] ID;
    private ProgressBar process;
    private ImageButton imgBtn;
    private ImageView imageview;


    public ImageAdapter(Activity c,Integer[] images) {
        this.mContext = c;
        this.Images=images;
        TypedArray attr = mContext.obtainStyledAttributes(R.styleable.HelloGal999lery);
        mGalleryItemBackground = attr.getResourceId(
                R.styleable.HelloGal999lery_android_galleryItemBackground, 0);
        attr.recycle();

        ID=new int[getCount()];
    }

    public int getCount() {
        return Images.length;
    }

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

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



    public View getView(final int position, View convertView,final ViewGroup parent) {  


         View rowView = convertView;

        if(rowView==null)
        {

         LayoutInflater inflater = mContext.getLayoutInflater();
         rowView = inflater.inflate(R.layout.test, null, true);

         imageview=(ImageView) rowView.findViewById(R.id.ImageViewuser);    
         imgBtn=(ImageButton)rowView.findViewById(R.id.Download);
         process=(ProgressBar)rowView.findViewById(R.id.progressbar_Horizontal);

         imageview.setImageResource(Images[position]);               
         imageview.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
         imageview.setBackgroundResource(mGalleryItemBackground);        


         if(position==0)
         {
             if(ID[position]==1)
             {
                 imgBtn.setVisibility(View.INVISIBLE);
                 process.setVisibility(View.VISIBLE);
             }          
         }

         if(ID[position]==position && position!=0)
         {
             imgBtn.setVisibility(View.INVISIBLE);
             process.setVisibility(View.VISIBLE);
         }               
        }                                                    
        else{
            Log.e("Else", "Else case");     
        }

        imgBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {               
                // TODO Auto-generated method stub  
                if(position==0)
                {
                    ID[position]=1;                     
                }
                else
                {
                    ID[position]=position;
                }
                parent.getChildCount();
                Toast.makeText(mContext, position+"", Toast.LENGTH_SHORT).show();
                parent.getChildAt(position).findViewById(R.id.progressbar_Horizontal).setVisibility(View.VISIBLE);          
                BackgroundAsyncTask objDownload=new BackgroundAsyncTask(parent,position);
                objDownload.execute();
            }

        }); 
         return rowView;                    
    }



    private class BackgroundAsyncTask extends
        AsyncTask<Void, Integer, Void> {

      public BackgroundAsyncTask(ViewGroup vg,int position) {       
            this.subGroup=vg;   
            this.pos=position;
        }

    int myProgress; 
    private ViewGroup subGroup;
    private int pos;

      @Override
      protected void onPostExecute(Void result) {
       // TODO Auto-generated method stub


          subGroup.getChildAt(pos).findViewById(R.id.Download).setVisibility(View.VISIBLE);         
          subGroup.getChildAt(pos).findViewById(R.id.progressbar_Horizontal).setVisibility(View.INVISIBLE);             
          Toast.makeText(mContext,"Download finished "+pos, Toast.LENGTH_SHORT).show();

          ID[1]=0;

      }

      @Override
      protected void onPreExecute() {
       // TODO Auto-generated method stub           
       myProgress = 0;
       imgBtn.setVisibility(View.INVISIBLE);
      }

      @Override
      protected Void doInBackground(Void... params) {
       // TODO Auto-generated method stub
       while(myProgress<100){
        myProgress++;
        publishProgress(myProgress);
           SystemClock.sleep(100);               
       }
    return null;              
}

        protected void onProgressUpdate(Integer... values) {

            process.setProgress(values[0]);

      }
     }      
}
  • 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-01T13:00:45+00:00Added an answer on June 1, 2026 at 1:00 pm

    Fix your getView

    public View getView(final int position, View convertView,final ViewGroup parent) {  
    
    
         View rowView = convertView;
    
        if(rowView==null)
        {
    
         LayoutInflater inflater = mContext.getLayoutInflater();
         rowView = inflater.inflate(R.layout.test, null, true);
    
         imageview=(ImageView) rowView.findViewById(R.id.ImageViewuser);    
         imgBtn=(ImageButton)rowView.findViewById(R.id.Download);
         process=(ProgressBar)rowView.findViewById(R.id.progressbar_Horizontal);
         }
    
         imageview.setImageResource(Images[position]);               
         imageview.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
         imageview.setBackgroundResource(mGalleryItemBackground);        
    
    
         if(position==0)
         {
             if(ID[position]==1)
             {
                 imgBtn.setVisibility(View.INVISIBLE);
                 process.setVisibility(View.VISIBLE);
             }          
         }
    
         if(ID[position]==position && position!=0)
         {
             imgBtn.setVisibility(View.INVISIBLE);
             process.setVisibility(View.VISIBLE);
         }               
    
        imgBtn.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {               
                // TODO Auto-generated method stub  
                if(position==0)
                {
                    ID[position]=1;                     
                }
                else
                {
                    ID[position]=position;
                }
                parent.getChildCount();
                Toast.makeText(mContext, position+"", Toast.LENGTH_SHORT).show();
                parent.getChildAt(position).findViewById(R.id.progressbar_Horizontal).setVisibility(View.VISIBLE);          
                BackgroundAsyncTask objDownload=new BackgroundAsyncTask(parent,position);
                objDownload.execute();
            }
    
        }); 
         return rowView;                    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In ma application I am using a gallery widget having an ImageView and a
Is there any way creating a photo gallery using Listview control ? Im playing
I am using a bespoke Jquery/PHP gallery script which pulls images from a Flickr
I am using a Gallery based Cover-flow, as suggested here . Is there an
I'm writing an application that shows a lot of images (currently using Gallery, but
We are using SuperSlidShow Plugin to display gallery of images in our post. However
I made a simple gallery, using this script to show the images: $rs =
I want to set images of my gallery using files in assest folder.
I'm new in android, here i'm using Gallery to show images in my application,
I am using fancybox on a series of gallery images. The user has the

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.