如何在 BroadcastReceiver 中更改 UI 颜色?

How to change UI colors at BroadcastReceiver?

我有一个用于更新数据库的警报管理器"s values.When user starts to alarm,My broadcastReceiver is activeted.There is another alarm in my BroadcastReceiver that İt always active when first alarm launch that It works only once.My BroadcastReceiver works but It doesn"t 做我 say.My 目的 is:Updating UI 和 colors.I 有 3 个 if 循环更新我的 database.My 问题是我更新了我的数据库,但是当更新我的数据库时,第三个循环没有 work.I 正在使用 Toast 来理解。我该如何解决它?

第一个效果不错:

if( !listDataBoya.contains("#1eac02")){
    Toast.makeText(context, "Alarm !!!!!!!!!!1111111111", Toast.LENGTH_LONG).show();


    String table = "people_table";
    ContentValues productDetailsContentValues = new ContentValues();
    productDetailsContentValues.put("boya", "#1eac02");
    String where = " id = " + listDataId.get(secilmissayı);
    mDatabaseHelper.update(table, productDetailsContentValues, where , null);

    setalarm(context);

}

第二个效果不错:

 if (listDataBoya.get(secilmissayı) != "#1eac02" ){

           String table = "people_table";
           ContentValues productDetailsContentValues = new ContentValues();
           productDetailsContentValues.put("boya", "#1eac02");
           String where = " id = " + listDataId.get(secilmissayı);
           mDatabaseHelper.update(table, productDetailsContentValues, where , null);
           Toast.makeText(context, "Alarm !!!!!!!!!!22222222"+ listDataBoya.get(secilmissayı), Toast.LENGTH_LONG).show();
           setalarm(context);

 }

第三个"t work: (I can"没看到我的 Toast。)

if (listDataBoya.get(secilmissayı) ==  "#1eac02" ){
       Toast.makeText(context, "Alarm !!!!!!!!!!333333333", Toast.LENGTH_LONG).show();

        String table = "people_table";
        ContentValues productDetailsContentValues = new ContentValues();
        productDetailsContentValues.put("boya", "#1eac02");
        String where = " id = " + listDataId.get(secilmissayı);
        mDatabaseHelper.update(table, productDetailsContentValues, where , null);

        setalarm(context);}

您的第三个示例未触发,因为您正在将字符串对象与 == 进行比较,您应该使用 equals 方法,如果参数是表示与您正在比较的字符串对象相同的字符序列。同样,您应该相应地更改其他示例。

if(listDataBoya.get(secilmissayı).equals("#1eac02")){
    ...
}