blk123
blk123

Reputation: 31

Reload Image using picasso

I'm using picasso to load url image to my image view.The image will change within the same url so added a refresh button to reload the new image. any help?

 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);
}

}

Upvotes: 1

Views: 1428

Answers (1)

blk123
blk123

Reputation: 31

I added this line and it's working fine now.

Picasso.with(this).invalidate();

Upvotes: 2

Related Questions