比如說,獲取EditText的內容
EditText et_content = (EditText)findViewById(R.id.content);
String content = et_content.getText().toString();
我查看到getText()返回的是Editable,為什麼Editable可以通過toStirng()轉換成String類型?
EditText 中getText
@Override
public Editable getText() {
return (Editable) super.getText();
}
super.getText();返回的還是一個CharSequence,然後被轉型成了Editable
public CharSequence getText() {
return mText;
}
public interface Editable
extends CharSequence, GetChars, Spannable, Appendable
{
}