在 Android 应用程序中设置工作日的背景颜色

setbackground color for week day in Android app

我正在 Android 开发一周数据应用程序。我想为工作日(例如:星期五)设置 背景颜色 。我在 xml 中使用 listview。非常感谢您的建议,

 private void addDateView(LinearLayout layout, String text,
        boolean isCurrentDay) {
    listview child = new listview(layout.getContext());



    if (isCurrentDay) {
        child.setBackgroundColor(Color.rgb(242, 199, 125));
    } else {
        child.setBackgroundColor(Color.WHITE);
    }

    child.setGravity(Gravity.CENTER);
    child.setTextColor(Color.RED);
    [enter image description here][1]child.setPadding(8, 8, 8, 8);
    layout.addView(child, (SCREEN_WIDTH / 7), 50);
}

要获得这一天,请执行以下操作:

Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK); 

根据日期设置背景:

switch (day) {
case Calendar.SUNDAY:


case Calendar.MONDAY:

}

依此类推,将您的更改逻辑放入案例中。