title: Transfer data from EditText to TextView of another activity using setText and onClickListener?
body: <p>I am a newbie.. I am trying to get text on another activity which I have created, from an activity created apriori. I could do this using <code>onClickListener</code>, but I am unable to get it done using <code>onClick</code> and <code>setText()</code>. The code runs well until the second activity, but when I type and send button, the code crashes. Help me! </p>
  
  <p>Here's the XML file:</p>
  
  <pre><code> &lt;TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout="@+id/tv1"
       android:text="@string/hello_world" /&gt;
  </code></pre>
  
  <p>Here's the Java file:</p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          Button bt = (Button) findViewById(R.id.bt1);
          bt.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
                  // TODO Auto-generated method stub
  
                  Intent intent = new Intent(MainActivity.this,
                          DisplayMessageActivity.class);
                  EditText et = (EditText) findViewById(R.id.et1);
                  String message = et.getText().toString();
                  intent.putExtra(EXTRA_MESSAGE, message);
                  startActivity(intent);
  
              }
          });
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  }
  </code></pre>