Android工作室中的Android偏好设置错误

时间:2017-09-26 04:56:46

标签: android

我做了一些设置活动。当我做出意图时,它发生了错误。它说""   java.lang.NoClassDefFoundError:解析失败:Landroid / support / v7 / app / AppCompatActivity; "

他们说" alt_logout.setPositiveButton("是",新的DialogInterface.OnClickListener()"这段代码有问题。我不知道我能做什么。帮助我......

final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {

            @Override
            public void onDateSet(DatePicker view, int year, int monthOfYear,
                                  int dayOfMonth) {
                // TODO Auto-generated method stub
                myCalendar.set(Calendar.YEAR, year);
                myCalendar.set(Calendar.MONTH, monthOfYear);
                myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                updateLabel();
            }

        };

     edittext.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                new DatePickerDialog(DetailsActivity.this, date, myCalendar
                        .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
                        myCalendar.get(Calendar.DAY_OF_MONTH)).show();
            }
        });
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                readCalendar();
            }
        });
    }
    private void readCalendar() {

        Intent intent = new Intent(Intent.ACTION_INSERT);
        intent.setData(CalendarContract.Events.CONTENT_URI);

        Calendar cal = Calendar.getInstance();
        edittext.setSelected(true);
        long startTime = cal.getTimeInMillis()+24*60*60*1000;
        long endTime = startTime+ 60 * 30 * 1000;

        intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime);
        intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime);
        intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, false);

        intent.putExtra(CalendarContract.Events.TITLE, "DOCTOR APPOINTMENT");

        startActivity(intent);
    }

    private void updateLabel() {
        String myFormat = "MM/dd/yy";
        SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
        edittext.setText(sdf.format(myCalendar.getTime()));
    }

1 个答案:

答案 0 :(得分:0)

更改

 AlertDialog.Builder alt_logout = new AlertDialog.Builder(activity);

 AlertDialog.Builder alt_logout = new AlertDialog.Builder(getApplicationContext());