1

这是我的主要活动代码包含错误

 public class MainActivity extends Activity{  
     static EditText bdayText;
     DBHandler dbHandler = new DBHandler(this); 
   @Override 
protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);    
}

日期选择器方法

public void selectDate(View view) {

        DialogFragment newFragment = new DialogFragment();
        newFragment.show(getFragmentManager(), "DatePicker");

    }
  public static void setTheDate(int year, int month, int day) {
        having error in this line
          bdayText = (EditText)MainActivity().findViewById(R.id.editText5);
          bdayText.setText(day+"/"+month+"/"+year);
        }
 public static class SelectDateFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
     @Override
     public Dialog onCreateDialog(Bundle savedInstanceState) {


         final Calendar c = Calendar.getInstance();
         int yy = c.get(Calendar.YEAR);
         int mm = c.get(Calendar.MONTH);
         int dd = c.get(Calendar.DAY_OF_MONTH);

         DatePickerDialog dialog = new DatePickerDialog(getActivity(),this,c.YEAR, c.MONTH, c.DATE);

         dialog.getDatePicker().setCalendarViewShown(false);
         dialog.setTitle("Pick a date");
         return dialog;
     }
     public void onDateSet(DatePicker view, int yy, int mm, int dd) {

         setTheDate(yy, mm+1, dd);
     }
4

0 回答 0