title: Check if TextView is empty?
body: <p>I am displaying a date in a <a href="https://developer.android.com/reference/android/widget/TextView" rel="nofollow noreferrer"><code>TextView</code></a>. It is all working fine when there is some date. But if no date is chosen or if the <a href="https://developer.android.com/reference/android/widget/TextView" rel="nofollow noreferrer"><code>TextView</code></a> is empty (there is a hint "dd-mm-yyyy" though) then the app crashes. I am checking for empty <a href="https://developer.android.com/reference/android/widget/TextView" rel="nofollow noreferrer"><code>TextView</code></a> as follows: <code>if(textview.setText().toString().isEmpty()) {//show error}</code> can anyone help what I am doing wrong?</p>
  
  <p>Initialisation of <a href="https://developer.android.com/reference/android/widget/TextView" rel="nofollow noreferrer"><code>TextView</code></a> and <a href="https://developer.android.com/reference/android/support/design/widget/TextInputLayout" rel="nofollow noreferrer"><code>TextInputlayout</code></a>:</p>
  
  <pre><code>tv_Current_Date = (TextView) findViewById(R.id.tv_Current_Date);
  til_Current_Date = (TextInputLayout) findViewById(R.id.til_Current_Date);
  </code></pre>
  
  <p>Here is the code responsible for crash:</p>
  
  <pre><code>if (tv_Current_Date.getText().toString().isEmpty()) {
      til_Current_Date.setError("Please choose a date");
  }
  </code></pre>
  
  <p>Method to set date:</p>
  
  <pre><code>public void setCurrentDateOnView() {
      String dateFormat = "dd-MM-yyyy";
      SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat, Locale.US);
      tv_Current_Date = (TextView) findViewById(R.id.tv_Current_Date);
      tv_Current_Date.setText(simpleDateFormat.format(calendar_now.getTime()));
      String short_weekday = new DateFormatSymbols().getShortWeekdays()[day_of_current_week];
      tv_Current_weekday.setText(short_weekday);
  }
  </code></pre>