-1
特殊日期的商店警告对话框我有在日期存储在日期列 日期 2017年1月2日显示SQLite中
我想显示警告对话框,如果当前日期数据库日期01相匹配的数据库文件/ 02/2017年
与编辑短信警告对话框得到的东西输入
我有下面的代码,代码 没有错误,但无法显示警告对话框, 任何一个可以帮助?
Date date = new Date();
DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getBaseContext());
//the above code will give the current date
String dbdate = databaseHelper.inserteddate(); //dbdate stored date from database
if (dateFormat.equals(dbdate)) // compare current date with db date
{
final AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle("new date");
alert.setMessage("enter new date");
final EditText editText = new EditText(context);
alert.setView(editText);
alert.setPositiveButton("yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String s = editText.getEditableText().toString();
}
});
alert.setNegativeButton("no", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alertDialog = alert.create();
alertDialog.show();
}
'dateFormat.equals(dbdate)'错误,您需要将'dbdate'转换为'Date'对象,然后您可以将它与'other Date'对象进行比较。 –
您可以使用其他方式进行检查 –