ImageView place at center on click in gallery view

Posted by TGMCians on Stack Overflow See other posts from Stack Overflow or by TGMCians
Published on 2012-11-20T04:55:38Z Indexed on 2012/11/20 4:59 UTC
Read the original article Hit count: 171

Filed under:
|

i used gallery view in which i place multiple imageview dynamically but on click imageview place at center and second question how to start first imageview from left of screen.

I do not want to change the place until user scroll horizontally by finger . Is there any way to achieve this. Please help for this..

     private  class ImageAdapter extends BaseAdapter{

         public ImageAdapter() {
            //To set blank at bottom and make visible
            TextView textView = (TextView)findViewById(R.id.textView2);
            textView.setVisibility(View.VISIBLE);

            //To set the visibility visible of gallery
            myGallery.setVisibility(View.VISIBLE);
         }
         public int getCount() {
             return ProductItemArray.Image_URL.length;
         }

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

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

         public View getView(int position, View arg1, ViewGroup arg2) {
             ImageView bottomImageView = new ImageView(context);

             if(Helper.isTablet(context))
                 bottomImageView.setLayoutParams(new Gallery.LayoutParams(VirtualMirrorActivity.convertDpToPixel(100, context), VirtualMirrorActivity.convertDpToPixel(100, context)));
             else
                 bottomImageView.setLayoutParams(new Gallery.LayoutParams(VirtualMirrorActivity.convertDpToPixel(80, context), VirtualMirrorActivity.convertDpToPixel(80, context)));

             UrlImageViewHelper.setUrlDrawable(bottomImageView, ProductItemArray.Image_URL[position]);
             bottomImageView.setBackgroundResource(R.layout.border);

             return bottomImageView;
         }

    }

myGallery.setAdapter(new ImageAdapter());
            myGallery.setSelection(1);
            myGallery.setOnItemClickListener(new OnItemClickListener()
            {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, final int position, long arg3)
                {
                    linearLayout.removeView(frameImageView);
                    Thread newThread = new Thread(new Runnable() {
                        public void run() {
                            URL url_1 = null;
                            try {
                                isAlreadyExistInWishlist = false;
                                VMProductListPaging.productUrl = ProductItemArray.Image_small_URL[position];
                                VMProductListPaging.productId = ProductItemArray.productId[position];
                                VMProductListPaging.productName = ProductItemArray.product_Name[position];

                                url_1 = new URL(ProductItemArray.Image_small_URL[position]);
                                bmp = BitmapFactory.decodeStream(url_1.openConnection().getInputStream());
                                isExecuted = true;
                                bitmapHandler.sendMessage(bitmapHandler.obtainMessage());
                            }
                            catch (Exception e) {
                                //Toast.makeText(context,"Sorry!! This link appears to be broken",Toast.LENGTH_LONG).show();
                            }
                        }
                    });
                    newThread.start();
                }
            });

Layout.xml

            <Gallery android:id="@+id/galleryView"  android:layout_width="fill_parent" android:layout_height="wrap_content"  
                android:spacing="5dp" android:layout_below="@+id/sendPhoto" android:layout_marginTop="10dp" android:visibility="gone"/> 

© Stack Overflow or respective owner

Related posts about android

Related posts about android-gallery