前人未踏の領域へ Androidアプリ開発編

Androidアプリ開発に関する調査メモ置き場。古い記事にはアプリ以外も含まれます。

TextView.setTextにnullをセットするとどうなるか

答え:サイズ0の文字列に置き換わる。

//android.widget.TextViewのソース抜粋
 private void setText(CharSequence text, BufferType type,
                             boolean notifyBefore, int oldlen) {
   if (text == null) {
            text = "";
   }

…以下略

バージョン1.6の頃からだから基本的にnullセットは気にしなくて良い。
参考
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.6_r2/android/widget/TextView.java#TextView.setText%28java.lang.CharSequence%2Candroid.widget.TextView.BufferType%29