After adding a view to the ViewFlipper
in the for statement, click ImageView
on a specific page.
I would like to change it.
For example, you have a ViewFlipper
with 25 pages of views, and you want to change the ImageView
on the second page.
I googled getChildAt
to get a view on page 2, but I don't know how to update the ImageView
image for that view.
Could you please let me know?
private ViewFlipper;
private View fl;
for(inti=0;i<itemList.size();i++){
LayoutInflater inflater=getLayoutInflater();
LinearLayoutoViewFlipperChildLayout=(LinearLayout)inflater.inflate(R.layout.imageview, null);
TextView textView= (TextView) oViewFlipperChildLayout.findViewById (R.id.image_Text);
ImageView imageView= (ImageView) oViewFlipperChildLayout.findViewById (R.id.image_View);
Strings=getResources().getString(itemList.get(i));
textView.setText(s);
myImage=BitmapFactory.decodeResource(resM,itemList.get(i));
imageView.setImageBitmap(myImage);
viewflipper.addView(oViewFlipperChildLayout);
}
viewflipper.post(new Runnable(){
@ Override
public void run() {
fl = viewflipper.getChildAt(1);
}
});
It's solved, so it's self-less.
Instead of post, I was able to replace the viewflipper that I had already created by doing the following:
private ViewFlipper;
private View fl;
for(inti=0;i<itemList.size();i++){
LayoutInflater inflater=getLayoutInflater();
LinearLayoutoViewFlipperChildLayout=(LinearLayout)inflater.inflate(R.layout.imageview, null);
TextView textView= (TextView) oViewFlipperChildLayout.findViewById (R.id.image_Text);
ImageView imageView= (ImageView) oViewFlipperChildLayout.findViewById (R.id.image_View);
Strings=getResources().getString(itemList.get(i));
textView.setText(s);
myImage=BitmapFactory.decodeResource(resM,itemList.get(i));
imageView.setImageBitmap(myImage);
viewflipper.addView(oViewFlipperChildLayout);
}
LinearLayout v=(LinearLayout)viewflipper.getChildAt(3);
TextView tv=(TextView) v.getChildAt(0);
ImageView = (ImageView) v.getChildAt(1);
Strings=getResources().getString(itemList.get(1));
tv.setText(s);
myImage=BitmapFactory.decodeResource(resM,itemList.get(1));
im.setImageDrawable(null);
im.setImageBitmap(null);
im.setImageBitmap(myImage);
viewflipper.removeViewAt(3);
viewflipper.addView(v,3);
© 2024 OneMinuteCode. All rights reserved.