我正在使用picasso将url图像加载到我的图像视图。图像将在同一个url中更改,因此添加了一个刷新按钮来重新加载新图像。有什么帮助吗?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}
@Override
public void onResume() {
super.onResume(); // Always call the superclass method first
ImageView v = (ImageView) findViewById(R.id.iv3);
Picasso.with(this).load("http://xxxxx/cgi-bin/video.JPG").into(v);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
else if(id==R.id.refresh){
onResume();
}
return super.onOptionsItemSelected(item);
}
}
答案 0 :(得分:2)
我添加了这一行,现在它正常工作。
Picasso.with(this).invalidate();