2
我已創建自定義視圖ComplexView
與EditText
內。在他的佈局中,我有片段DetailsFragment
和3 ComplexView
。當我在DetailsFragment
輸入的值(A,B,C),然後按下並彈出一個片段都editTexts具有相同的價值C.我實現的onSaveInstanceState
和onRestoreInstanceState
自己的版本,並沒有幫助。哪裏不對?如何檢索自定義視圖的狀態?
@Override
protected Parcelable onSaveInstanceState() {
Bundle bundle = new Bundle();
bundle.putParcelable(STATE_SUPER_STATE, super.onSaveInstanceState());
bundle.putString(STATE_DESCRIPTION_TEXT, mDescription.getText().toString());
return bundle;
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle)state;
super.onRestoreInstanceState(bundle.getParcelable(STATE_SUPER_STATE));
mDescription.setText(bundle.getString(STATE_DESCRIPTION_TEXT));
} else {
super.onRestoreInstanceState(state);
}
}
約80%。數據如何輸入? – 2014-09-23 15:18:03