使用picasso重新加载图像

vmpqdwk3  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(293)

我正在使用毕加索将url图像加载到我的图像视图中。图像将在同一url中更改,因此添加了一个刷新按钮以重新加载新图像。有什么帮助吗?

  1. protected void onCreate(Bundle savedInstanceState) {
  2. super.onCreate(savedInstanceState);
  3. setContentView(R.layout.activity_main2);
  4. }
  5. @Override
  6. public void onResume() {
  7. super.onResume(); // Always call the superclass method first
  8. ImageView v = (ImageView) findViewById(R.id.iv3);
  9. Picasso.with(this).load("http://xxxxx/cgi-bin/video.JPG").into(v);
  10. }
  11. @Override
  12. public boolean onOptionsItemSelected(MenuItem item) {
  13. // Handle action bar item clicks here. The action bar will
  14. // automatically handle clicks on the Home/Up button, so long
  15. // as you specify a parent activity in AndroidManifest.xml.
  16. int id = item.getItemId();
  17. //noinspection SimplifiableIfStatement
  18. if (id == R.id.action_settings) {
  19. return true;
  20. }
  21. else if(id==R.id.refresh){
  22. onResume();
  23. }
  24. return super.onOptionsItemSelected(item);
  25. }

}

vxbzzdmp

vxbzzdmp1#

我加了这条线,现在很好用。 Picasso.with(this).invalidate();

相关问题