// Documentation from interface
public SpannableStringBuilder append(CharSequence text) {
int length = length();
return replace(length, length, text, 0, text.length());
}
SpannableStringBuilder
source code append()
function doesn't avoid NullPointerException
?? If text is null, append()
function definitely throw NullPointerException
. It's easily be forgotten to check every case if text is null. For example the text may from the server. Anyone has a better idea for SpannableStringBuilder
append()
function to avoid npe?
您可以将SpannableStringBuilder
包装在您自己的类中并将null
检查放在那里。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.