ふと、TextView.setText(null)の挙動が気になったので調査しました。
http://tools.oesf.biz/android-4.4.2_r1.0/xref/frameworks/base/core/java/android/widget/TextView.java
@android.view.RemotableViewMethod
public final void setText(CharSequence text) {
setText(text, mBufferType);
}
上記が developer との APIの界面です。これは、以下のsetText(CharSequence text, BufferType type)を呼んでいます。
public void setText(CharSequence text, BufferType type) {
setText(text, type, true, 0);
if (mCharWrapper != null) {
mCharWrapper.mChars = null;
}
}
さらに、setTextsetText(CharSequence text, BufferType type,boolean notifyBefore, int oldlen)を呼び出しています。
private void setText(CharSequence text, BufferType type,
boolean notifyBefore, int oldlen) {
if (text == null) {
text = "";
}
その中で text が null の場合、”"(空文字)が入っているので、安全のようです。

