0

在用户通过 DatePickerDialog 输入日期后,我调用了 onResume() 来更新我的显示。这行得通。但是在新版本中,我使用的是 DatePickerFragment ,这不再有效。

public void onDateSet(DatePicker view, int year, int month, int day) 
 {  // Do something with the date chosen by the user
    userSetYear=year;
    userSetMonth=month;
    userSetDay=day;
    userSetDate=true;
    onResume(); //activates the wrong onResume, has no affect on display
    //MainActivity.onResume();//error message : Cannot make a static reference to          the     non-static method onResume() from the type MainActivity
}
4

1 回答 1

0

你不应该调用 onResume() 方法,它是关于活动本身的生命周期的。但这里有一个链接给你:在 Android 的活动中调用 onResume

此外,您可能还想了解 Android 中的生命周期管理;http://developer.android.com/training/basics/activity-lifecycle/index.html

于 2013-08-08T14:36:20.977 回答