我想显示图像存储在一个arraylist到一个imageview.I使用picasso库来存储links.When我按下按钮,我希望图片更改为接下来image.I正在使用的循环,但我只得到了最后element.Here是代码:Android Studio显示元素的Arraylist上ImageView
ImageView image1;
Button bNext,
ArrayListll=new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fwtografies);
image1=(ImageView)findViewById(R.id.image1);
bNext=(Button)findViewById(R.id.bNext);
ll.add("http://i.imgur.com/QoUeA2I.jpg");
ll.add("http://i.imgur.com/21szRz9.jpg");
ll.add("https://upload.wikimedia.org/wikipedia/en/e/ec/Clip_Poster.jpg");
bBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent fwtografiesActivityIntent = new Intent(Fwtografies.this,MainActivity.class);
Fwtografies.this.startActivity(fwtografiesActivityIntent);
}
});
bNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
for(int i=0;i
sp(ll.get(i),image1);
}
}
});
bPrevius.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
viewFlipper.showPrevious();
}
});
sp("http://i.imgur.com/gijIKJO.jpg",image1);
//sp("http://i.imgur.com/QoUeA2I.jpg",image2);
//sp("http://i.imgur.com/21szRz9.jpg",image3);
}
public void sp(String a,ImageView b){
Picasso
.with(getApplicationContext())
.load(a)
.into(b);
}}