title: How to update a TextView of an Activity from another class
body: <p>I am new to Android/Java programming. I have two classes, one is an <code>Activity</code> and the other is a normal class. My activity class contains a <code>TextView</code>. Can I update the <code>TextView</code> of the activity class from a normal class? I tried with random code, but it fails.</p>
  
  <pre><code>// activity class
  public class MainMenu extends Activity {
      public TextView txtView;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          TextView txtView = (TextView)findViewById(R.id.text);   
      }
  }
  
  // Other class
  public class ClassB {
      public ClassB() {
          public void Update() {
              TextView txtView = (TextView)findViewById(R.id.text);
              txtView.setText("Hello");
          }
      }
  }
  </code></pre>