我使用了库视图,其中我动态放置了多个图像视图但是在点击图像视图时它出现在中心,第二个问题是如何从屏幕左侧开始第一个图像视图。
我不想改变这个地方,直到用户用手指水平滚动。有没有办法实现这一目标。请帮忙...
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"/> `enter code here`