1) in xml
======
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.55"
android:orientation="vertical" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/llGallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:orientation="horizontal"
android:scrollbars="vertical" >
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
======
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.55"
android:orientation="vertical" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/llGallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:orientation="horizontal"
android:scrollbars="vertical" >
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
2) In Activity
private LinearLayout llGallery;
private ImageView t1ourstoreContentImg;
private ImageView t1ourstoreContentImg;
public class ABC extends activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_activity);
llGallery = (LinearLayout) v.findViewById(R.id.llGallery);
JSONArray product_images = mDetails.getJSONArray("product_images");
int imagesLength = product_images.length();
System.out.println("imagesLength=" + imagesLength);
for (int i = 0; i < imagesLength; i++) {
String url = product_images.getJSONObject(i).getString("url");
ImageView imagView = new ImageView(getActivity());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
100, 100);
lp.setMargins(3, 3, 3, 3);
imagView.setLayoutParams(lp);
imagView.setTag(url);
mImageFetcher.loadImage(product_images.getJSONObject(i)
.getString("url_thumb"), imagView);
imagView.setAdjustViewBounds(true);
llGallery.addView(imagView);
imagView.setOnClickListener(new onMyClick(url,t1ourstoreContentImg));
mImageFetcher.loadImage(product_images.getJSONObject(0).getString("url"),
t1ourstoreContentImg);
}
}
public class onMyClick implements OnClickListener {
private final String mString;
public ImageView mImageView;
public onMyClick(String mString,ImageView mImageView) {
this.mString = mString;
this.mImageView = mImageView;
}
@Override
public void onClick(final View v) {
mImageFetcher.loadImage(mString, t1ourstoreContentImg);
}
}
}
bhai tere ko jab code likhna nai ata toh please for god sake dusroko galat mat batate ja please I beg to close your blog. Otherwise I have to take aginst of your blog.
ReplyDelete