我有三个字段
我的java代码是:
date_txtbx = (EditText) findViewById(R.id.date_txtbx);
date_txtbx.setText(" "
+ String.valueOf(java.text.DateFormat.getDateTimeInstance()
.format(Calendar.getInstance().getTime())));
next_due_on_txtbx = (EditText) findViewById(R.id.next_due_on_txtbx);
next_due_on_txtbx.setText(non_ticket_task.next_due_on);
status = (Spinner) findViewById(R.id.status_spinner);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.Status_array, android.R.layout.simple_dropdown_item_1line);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
status.setAdapter(adapter);
我希望在用户选择关闭状态时禁用下一个截止日期,如果用户输入下一个截止日期小于或等于当前日期,则显示错误消息“请插入大于当前日期的日期”。怎么可能?我只想在**EditText**
上进行这些验证。请指导。任何帮助都会很感激。
申请条件:
next_due_on_txtbx = (EditText) findViewById(R.id.next_due_on_txtbx);
next_due_on_txtbx.setText(non_ticket_task.next_due_on);
if (next_due_on_txtbx.after(date_txtbx))
{
Context count;
Toast.makeText(count, "Starting date cannot be before Current date", Toast.LENGTH_LONG).show();
}
答案 0 :(得分:1)
请检查
if (date1.after(date2))
{
Toast.makeText(Your_Current_Activity.this,
"Starting date cannot be before Current date", Toast.LENGTH_LONG).show();
}