Search code examples
androidtextviewandroid-log

Android Log.d not displaying because of textView.getText().toString()


The first two logs display fine, but the last one doesn't show up. Even if the second parameter of the last log has an issue, I'm still confused why the log doesn't just display with an error or something. Any help is appreciated.

@Override
public void onStart() {
    super.onStart();
    TextView country = (TextView) findViewById(R.id.country);
    Log.d("t1", "t1");
    Log.d("t2", country.toString());
    Log.d("t3", country.getText().toString());
}

Here is the log output:

02-07 05:10:16.877 23305-23305/---bundle id--- D/t1: t1
02-07 05:10:16.877 23305-23305/---bundle id--- D/t2: android.support.v7.widget.AppCompatTextView{381dd943 V.ED..C. ......I. 0,0-0,0 #7f0e0089 app:id/country}

Solution

  • As far as I'm aware, if the getText() method of the TextView object returns an empty string, the logger will not output an entry for it. You can try concatenating some text to describe what should be expected in the output. For example:

    Log.d("t3", "Country TextView Value: " + country.getText().toString());