title: How can i add a TextView to an existing RelativeLayout programmatically?
body: <p>I've searched for other similiar questions, and i've found some, but strangely they don't work for me, and i don't know what i'm doing wrong...</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  EditText item;
  Button insert;
  RelativeLayout layout;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      item = (EditText) findViewById(R.id.item);
      layout = (RelativeLayout) findViewById(R.id.layout);
  }
  
  @Override
  public void onResume() {
      super.onResume();
  
      insert.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              String s_item = item.getText().toString();
              TextView tv = new TextView(MainActivity.this);
  
              layout.addView(tv);
              tv.setText(s_item);
          }
      });
  }
  
  }
  </code></pre>
  
  <p>when the app starts, it just crashes... and the problem is in this code apparently...</p>
  
  <p>LOGCAT</p>
  
  <pre><code>08-18 14:37:19.425    2981-2981/? E/AndroidRuntime: FATAL EXCEPTION: main
      java.lang.RuntimeException: Unable to resume activity {g.d.raven/g.d.raven.MainActivity}: java.lang.NullPointerException
      at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2124)
      at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672)
      at android.app.ActivityThread.access$1500(ActivityThread.java:117)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:130)
      at android.app.ActivityThread.main(ActivityThread.java:3687)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:507)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
      at dalvik.system.NativeStart.main(Native Method)
      Caused by: java.lang.NullPointerException
      at g.d.raven.MainActivity.onResume(MainActivity.java:30)
      at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
      at android.app.Activity.performResume(Activity.java:3832)
      at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2114)
      ... 12 more
  08-18 14:37:19.429      130-143/? E/: Dumpstate &gt; /data/log/dumpstate_app_error
  </code></pre>
  
  <p>Thank you all, i found it by myself just now, forgot to instantiate the button XD</p>