2

help me i use this sample example http://www.androidhub4you.com/2012/10/custom-calendar-in-android.html?showComment=1374298656772#c7739428050175524218 I want to print only current week of days. i want to display only single row. i modify this example code to my code. I replaced example code with this condition: if (i == currentWeekDay). But it only display first week of dates. Today's date is 20 july. Is does not show today date of week. My screen looks like this:

enter image description here

how i display current week only??

// 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);
        }
        }
    }
Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124
user2589245
  • 721
  • 2
  • 11
  • 23

2 Answers2

0

please try https://github.com/roomorama/Caldroid

U can also customize the custom calender according to your requirement.

Karan Maru
  • 991
  • 6
  • 17
  • ok thnx tell me one more thing how i print this values in log cat?? http://stackoverflow.com/questions/7440719/how-can-i-get-all-the-days-of-the-current-week-in-android Answer 4 sample code – user2589245 Jul 20 '13 at 08:41
  • define an array of days of week. Then initialize calender and set the date to the calender which you required, then u can get the days according to date, U can store it into String and then u can display it into log cat. – Karan Maru Jul 20 '13 at 08:54
  • i do not want hardcoded dates i want what ever week is current week dates – user2589245 Jul 20 '13 at 08:58
  • please go through given link and add the caldroid library into your project and made changes according to your requirement, I hope you will get the solution of your problem and also study the Sample Project given in it, It will be helpful for U. – Karan Maru Jul 20 '13 at 09:05
  • IS NOT HELP ME I JUST WANT TO PRINT CURRENT DAAYS OF WEEK – user2589245 Jul 20 '13 at 10:40
0

Try this code-

// 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);
                }
Manish Srivastava
  • 1,649
  • 2
  • 15
  • 23
  • IS WORK THNX BUT IS JUST SHOW CURRENT Date only not tomrrow day after tomorrow and rest of week – user2589245 Jul 21 '13 at 22:13
  • I am sorry dear no one going to wrote your app for you.. I just given you logic.. try to add item after current date in list how many days rest in that week. you can remove break, also and then try to remove extra dates from your list as i have remove from the top.. – Manish Srivastava Jul 22 '13 at 04:48