title: Android - How can I access a View object instantiated in onCreate in onResume?
body: <p>In my <code>onCreate()</code> method, I'm instantiating an <code>ImageButton</code> View:</p>
  
  <pre class="lang-java prettyprint-override"><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.layout_post);
  
      final ImageButton ib = (ImageButton) findViewById(R.id.post_image);
  ...
  </code></pre>
  
  <p>In <code>onResume</code>, I want to be able to change the properties of the <code>ImageButton</code> with something like:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Override
  protected void onResume() {
      super.onResume();
      ib.setImageURI(selectedImageUri);
  }
  </code></pre>
  
  <p>But <code>onResume</code> doesn't have access to the <code>ib ImageButton</code> 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.</p>
  
  <p>Any suggestions on how to do this?</p>