所有..我是android新手。我尝试制作带有剩余警报的日历..我编写的所有内容都可以正常工作..但是“警报事件”仅在 LogCat 中作为 system.out.print 工作,但它无法在 android Emulator GUI 中显示。我通过使用线程在唤醒中制作了这个警报功能。在这个线程中,我想向 GUI 显示一个警告框。在这里我附上了代码。任何人都可以告诉如何在线程中显示消息吗?
编码:
public void run() {
for (;;) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm");
Calendar cal = Calendar.getInstance();
stime = dateFormat.format(cal.getTime());
arrCRInt = Long.parseLong(stime);
try {
i = 0;
c = db1.rawQuery("SELECT * FROM " + CRA, null);
if (c != null) {
if (c.moveToFirst()) {
do {
dbdatetime = c.getString(c.getColumnIndex("rdatetime"));
arrDBInt = Long.parseLong(dbdatetime);
remName = c.getString(c.getColumnIndex("rname"));
rem_id = c.getString(c.getColumnIndex("reminder_id"));
alertId=c.getString(c.getColumnIndex("alert"));
if (arrDBInt < arrCRInt) {
if(alertId.equals("TRUE"))
{
///////////////////// Passing Alert Message to Android Emulator GUI
db1.execSQL("UPDATE "+CRA+" SET "+ALERT+"='FALSE' WHERE reminder_id = " + rem_id );
}
db1.execSQL("UPDATE "+CRA+" SET "+STATUS+"='TRUE' WHERE "+CRDATETIME+"<"+arrCRInt +" and reminder_id = " + rem_id );
}
if (arrDBInt == arrCRInt) {
///////////////////// Passing Alert Message to Android Emulator GUI
System.out.println("ALERTED AS: You Have " + remName + " Remainder as on this Time");
db1.execSQL("UPDATE "+CRA+" SET "+ALERT+"='FALSE' WHERE "+CRDATETIME+"="+arrCRInt +" and reminder_id = " + rem_id );
}
if(arrDBInt>arrCRInt)
{
///////////////////// Passing Alert Message to Android Emulator GUI
//////////////////这里警报框,消息框,吐司等一切都不起作用
}
} while (c.moveToNext());
}
}
Thread.sleep(10000);
} catch (Exception e) {
}
}
}