如何显示当前的工作日

时间:2013-07-20 08:11:45

标签: android

帮助我使用此示例示例http://www.androidhub4you.com/2012/10/custom-calendar-in-android.html?showComment=1374298656772#c7739428050175524218我想只打印当前的一周。我想只显示单行。我将此示例代码修改为我的代码。我用这个条件替换了示例代码:if (i == currentWeekDay)。但它只显示第一周的日期。今天的日期是7月20日。是不显示今天的星期几。我的屏幕看起来像这样:

enter image description here

我如何仅显示当前周?

// Current Month Days
for (int i = 1; i <= daysInMonth; i++) {
 Log.d(currentMonthName, String.valueOf(i) + " "
  + getMonthAsString(currentMonth) + " " + yy);
 if (i == getCurrentDayOfMonth()) {
 list.add(String.valueOf(i) + "-BLUE" + "-"
   + getMonthAsString(currentMonth) + "-" + yy);
 } else {
 list.add(String.valueOf(i) + "-WHITE" + "-"
   + getMonthAsString(currentMonth) + "-" + yy);
 }
}

                    // Current Month Days
    for (int i = 1; i <= daysInMonth; i++) {
        Log.d(currentMonthName, String.valueOf(i) + " "
                + getMonthAsString(currentMonth) + " " +  
        yy);
        if (i == currentWeekDay)
        {

        if (i == getCurrentDayOfMonth()) {
            list.add(String.valueOf(i) + "-BLUE" + "-"
                    + getMonthAsString(currentMonth) 
    +    "-" + yy);
        } else {
            list.add(String.valueOf(i) + "-WHITE" + "-"
                    + getMonthAsString(currentMonth) + 
      "-" + yy);
        }
        }
    }

2 个答案:

答案 0 :(得分:0)

请尝试https://github.com/roomorama/Caldroid

您还可以根据需要自定义自定义日历。

答案 1 :(得分:0)

试试这段代码 -

// Current Month Days
            int startDate = 0;

                for (int i = 1; i <= daysInMonth; i++) {
                    Log.d(currentMonthName, String.valueOf(i) + " "
                            + getMonthAsString(currentMonth) + " " + yy);
                     startDate=getCurrentDayOfMonth()-(list.size() % 7);
                        System.out.println("**********"+startDate);
                       if (i == getCurrentDayOfMonth()) {

                        list.add(String.valueOf(i) + "-BLUE" + "-"
                                + getMonthAsString(currentMonth) + "-" + yy);

                        break;
                    } else {


                        list.add(String.valueOf(i) + "-WHITE" + "-"
                                + getMonthAsString(currentMonth) + "-" + yy);
                    }
                }

                //removing itmem fro list
                System.out.println("----------------------"+startDate);
                System.out.println(list.size());
                for(int k=1;k<=startDate;k++){
                    System.out.println("Item remove"+k);
                    list.remove(0);
                }