title: Saving data to TextView on different activity
body: <p>On home screen of my app I want to have various <code>TextViews</code> that initially hold only "..." for data, until user inputs his data.</p>
  
  <p>User inputs data in different activity that opens when <code>CardView</code> that holds all "..." values is clicked.</p>
  
  <p>I constantly get NullPointerException</p>
  
  <pre><code>02-26 16:14:33.106 26275-26275/hr.app.liftme.liftmehr E/AndroidRuntime: FATAL EXCEPTION: main
      Process: hr.app.liftme.liftmehr, PID: 26275                                                               
  
  java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
      at hr.app.liftme.liftmehr.StatistikeInputMain$1.onClick(StatistikeInputMain.java:54)
      at android.view.View.performClick(View.java:4856)
      at android.view.View$PerformClick.run(View.java:19956)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:211)
      at android.app.ActivityThread.main(ActivityThread.java:5389)
      at java.lang.reflect.Method.invoke(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:372)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
  </code></pre>
  
  <p>Here's my java file</p>
  
  <pre><code>public class StatistikeInputMain extends AppCompatActivity {
      RadioGroup radioGrupa;
      RadioButton imperial, metric;
      EditText visinaCM, visinaFT, visinaINC, tezina, bodyfat, tdee;
      Spinner kolikoDugoTrenirate, cilj;
      TextView rezultatTDEE;
      Button spremiRezultat;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_statistike_input_main);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          radioGrupa = (RadioGroup) findViewById(R.id.radioGrupaStatistike);
          imperial = (RadioButton) findViewById(R.id.radioStatistikeImperial);
          metric = (RadioButton) findViewById(R.id.radioStatistikeMetric);
          visinaCM = (EditText) findViewById(R.id.editTextStatistikeVisinaCM);
          visinaFT = (EditText) findViewById(R.id.editTextStatistikeVisinaFEET);
          visinaINC = (EditText) findViewById(R.id.editTextStatistikeVisinaINCH);
          tezina = (EditText) findViewById(R.id.editTextStatistikeTezina);
          bodyfat = (EditText) findViewById(R.id.editTextStatistikeBF);
          tdee = (EditText) findViewById(R.id.editTextStatistikeTDEE);
          kolikoDugoTrenirate = (Spinner) findViewById(R.id.spinnerStatistikeKolikoDugoTrenirate);
          cilj = (Spinner) findViewById(R.id.spinnerStatistikeCilj);
          spremiRezultat = (Button) findViewById(R.id.buttonStatistikeSpremi);
          rezultatTDEE = (TextView) findViewById(R.id.textViewStatistikeRezultatTDEE);
  
          spremiRezultat.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  double unosTDEE = Double.parseDouble(tdee.getText().toString());
  
                  double rezultatTDEEInput = 0;
                  rezultatTDEE.setText(Double.toString(rezultatTDEEInput));
              }
          });
      }
  }
  </code></pre>
  
  <p>Note that error occurs on this line</p>
  
  <pre><code>rezultatTDEE.setText(Double.toString(rezultatTDEEInput));
  </code></pre>
  
  <p>I want data to be saved on this Text View</p>
  
  <pre><code> &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="..."
      android:id="@+id/textViewStatistikeRezultatTDEE"
      android:textSize="14sp" /&gt;
  </code></pre>
  
  <p>That is initiallized and casted in java file..</p>
  
  <p>Another note - data is saved when the button is pressed!</p>
  
  <p>What am I missing here?</p>
  
  <p>EDIT</p>
  
  <ol>
  <li><p>activity</p>
  
  <pre><code>spremiRezultat.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
          Intent intent = new Intent(getApplicationContext(), AppLayoutMain.class);
          intent.putExtra("tdeeInput", tdee.getText().toString());
          startActivity(intent);
  </code></pre></li>
  <li><p>activity</p>
  
  <pre><code>Intent intent = getIntent();
  String tdee = intent.getStringExtra("tdeeInput");
  </code></pre></li>
  </ol>
  
  <p>I did it this way, only way that it doesn't give error, button works fine but it still doesn't display results.</p>