我正在使用毕加索将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);
}
}
1条答案
按热度按时间vxbzzdmp1#
我加了这条线,现在很好用。
Picasso.with(this).invalidate();