Android - How can I access a View object instantiated in onCreate in onResume?

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2011-01-17T18:26:27Z Indexed on 2011/01/17 18:53 UTC
Read the original article Hit count: 133

Filed under:
|
|

In my onCreate() method, I'm instantiating an ImageButton View:

public void onCreate(Bundle savedInstanceState) {
    Log.d(AntengoApplication.LOG_TAG, "BrowsePicture onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_post);

    final ImageButton ib = (ImageButton) findViewById(R.id.post_image);
...

In onResume, I want to be able to change the properties of the ImageButton with something like: @Override protected void onResume() { super.onResume(); ib.setImageURI(selectedImageUri); } //END onResume

But onResume doesn't have access to the ib ImageButton object. If this were a variable, I'd simple make it a class variable, but Android does not allow you to define View object in the class.

Any suggestions on how to do this?

© Stack Overflow or respective owner

Related posts about java

Related posts about android