Android プロジェクトに DatePickerFragment があります。
public class Uses extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
//code
}
public class parkingListHTTP extends AsyncTask<String, Void, String> {
//code
}
@Override
protected void onPostExecute(String result) {
//code
}
public void returnUses(String date) {
//code
}
public void selectDate(View v) {
DialogFragment newFragment = new DatePickerFragment();
newFragment.show(getSupportFragmentManager(), "datePicker");
}
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// Create a new instance of DatePickerDialog and return it
return new DatePickerDialog(getActivity(), this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
// Do something with the date chosen by the user
String dateText = context.getString(R.string.date_name);
String[] strDays = new String[]{"Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sáb"};
final Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month-1);
c.set(Calendar.DAY_OF_MONTH, day);
int week = c.get(Calendar.DAY_OF_WEEK);
date.setText(dateText.replaceFirst("\\*",strDays[week - 1] + " " + day + "/" + (month+1)+"/"+year));
returnUses(year+"-"+(month+1)+"-"+day);
}
}
}
プロジェクトのコードを変更すると、次の行
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
エラーを返します:
This fragment inner class should be static (com.usualbike.mandemo.Uses.DatePickerFragment)
しかし、プロジェクトのクリーニングで解決しました。
このエラーとクリーニングを回避するにはどうすればよいですか?