all ..我是android新手。我試着做一個日曆與餘數警報..一切我編碼和工作正常..但'警報事件'只在LogCat作爲system.out.print但它不會能夠顯示在Android模擬器GUI。我使用Thread來喚醒這個鬧鐘功能。 在這個線程我想顯示一個警報框到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) {
}
}
}
感謝兄弟..在那裏我可以插入這一個在線程類 – user1638214