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 に答える