使用CalendarView我需要显示旋转设备的特定月份。虽然我需要使用" setDate"要设置当前选择的日期,我还需要显示所显示的月份,该月份与所选日期完全不同。当设备旋转时,用户可能位于与当前所选月份完全不同的月份。我需要能够在新的方向上定位那个月。我无法找到办法做到这一点。
答案 0 :(得分:0)
static final String STATE_DATA = "data";
private String mData;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Check whether we're recreating a previously destroyed instance
if (savedInstanceState != null) {
// Restore value of members from saved state
mData = savedInstanceState.getString(STATE_DATA);
} else {
// Probably initialize members with default values for a new instance
mData = "NewData";
}
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putString(STATE_DATA, mData);
// Always call the superclass so it can save the view hierarchy state
super.onSaveInstanceState(savedInstanceState);
}
希望您了解Activity的生命周期。