How to retrieve textview text from main.xml
<p>I have following main.xml of layout </p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" &gt;

&lt;TextView
    android:id="@+id/textview01"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" /&gt;
</code></pre>

<p></p>

<p>and I am trying to retrieve the text i.e. @string/hello  by using the following code</p>

<pre><code>   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);



  TextView tv= (TextView) findViewById(R.id.textview01);
  String input= tv.getText().toString();

  Log.d("Info",input);
</code></pre>

<p>but I am not able to see the output. Application is crashing with NULL Exception error at the String input = tv.getText(</p>
