Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get change current date color?
    primarykey
    data
    text
    <p>below is my code which get current week dates and print in buttons how i change color of current date??? just only need to change the color of today date? how i will do that???? mDay is current date. change the color of today date to blue how is possible??</p> <pre><code> public class HoyahCalendar extends Activity { public static int mYear; public static int currentIndex = -1; public static int mMonth; public static int mDay; public static String[][] a = new String[6][7]; Calendar mCalendar = Calendar.getInstance(); mYear = mCalendar.get(Calendar.YEAR); mMonth = mCalendar.get(Calendar.MONTH) + 1; mDay = mCalendar.get(Calendar.DAY_OF_MONTH); public void showOnScreen() { if (mMonth ==1) { Monthname="January"; } else if (mMonth ==2) { Monthname="February"; } else if (mMonth ==3) { Monthname="March";} else if (mMonth ==4) { Monthname="April"; } else if (mMonth ==5) { Monthname="May";} else if (mMonth ==6) { Monthname="June"; } else if (mMonth ==7) { Monthname="July";} else if (mMonth ==8) { Monthname="August"; } else if (mMonth ==9) { Monthname="September";} else if (mMonth ==10) { Monthname="October"; } if (mMonth ==11) { Monthname="November";} else if (mMonth ==12) { Monthname="December"; } date_today.setText( Monthname + " " +mYear); e00.setText("" + a[0][0]); e01.setText("" + a[0][1]); e02.setText("" + a[0][2]); e03.setText("" + a[0][3]); e04.setText("" + a[0][4]); e05.setText("" + a[0][5]); e06.setText("" + a[0][6]); } public class ShowCalendar { int mYear; int mMonth; int mDay; public ShowCalendar(int mYear, int mMonth){ this.mYear = mYear; this.mMonth = mMonth; calculateMonthFirstday(); } public int getmDay() { return mDay; } public void setmDay(int mDay) { this.mDay = mDay; } public ShowCalendar(int mYear, int mMonth, int mDay, String time){ this.mYear = mYear; this.mMonth = mMonth; if (time == "next"){ HoyahCalendar.currentIndex++; if (HoyahCalendar.currentIndex == 5){ HoyahCalendar.currentIndex--; } this.mDay = mDay + 7; } else if (time == "last"){ HoyahCalendar.currentIndex--; if (HoyahCalendar.currentIndex == -1){ HoyahCalendar.currentIndex++; } this.mDay = mDay - 7; } calculateMonthFirstday(); } public void calculateMonthFirstday(){ int month, first_day=0; if((mYear%4==0 &amp;&amp; mYear%100!=0)||(mYear%400==0)) month=1; else month=0; int y, y12, c, c12, m, d; y = mYear%100; y12 = (mYear-1)%100; //only for January and February c = mYear/100; c12 = (mYear-1)/100; m = mMonth; d = 1; switch(mMonth){ case 1: {first_day = y12 + y12/4 +c12/4 - 2*c12 + 26*(13 + 1)/10 + d - 1;break;} case 2: {first_day = y12 + y12/4 +c12/4 - 2*c12 + 26*(14 + 1)/10 + d - 1;break;} case 4: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;} case 5: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;} case 6: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;} case 7: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;} case 8: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;} case 9: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;} case 10: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;} case 11: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;} case 12: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;} } if(first_day&lt;0) first_day = 7 - (Math.abs(first_day))%7;//first_day每月第一天星期几 else first_day = first_day%7; switch(mMonth){ case 1: {CalculateCalendar(1,first_day,31);break;} case 2: {CalculateCalendar(2,first_day,28+month);break;} case 3: {CalculateCalendar(3,first_day,31);break;} case 4: {CalculateCalendar(4,first_day,30);break;} case 5: {CalculateCalendar(5,first_day,31);break;} case 6: {CalculateCalendar(6,first_day,30);break;} case 7: {CalculateCalendar(7,first_day,31);break;} case 8: {CalculateCalendar(8,first_day,31);break;} case 9: {CalculateCalendar(9,first_day,30);break;} case 10:{CalculateCalendar(10,first_day,31);break;} case 11:{CalculateCalendar(11,first_day,30);break;} case 12:{CalculateCalendar(12,first_day,31);break;} } } public void CalculateCalendar(int month_no, int week_no, int month_days){ int i, s, targetRow = 0; int currentDay; if (this.mDay == 0){ currentDay= HoyahCalendar.mDay; }else { currentDay = this.mDay; } //String[][] a = new String[6][7]; for (i=0;i&lt;week_no;i++) HoyahCalendar.a[i/7][i%7] = ""; for(i=week_no; i&lt;week_no + month_days; i++){ s = i - week_no + 1; HoyahCalendar.a[i/7][i%7] = String.valueOf(s); if (s == currentDay &amp;&amp; HoyahCalendar.currentIndex == -1){ HoyahCalendar.currentIndex = i/7; } } for (i=0; i&lt;7;i++){ if (HoyahCalendar.a[HoyahCalendar.currentIndex][i] == null){ HoyahCalendar.a[0][i] = ""; }else{ HoyahCalendar.a[0][i] = HoyahCalendar.a[HoyahCalendar.currentIndex][i]; } } for(i=week_no+month_days; i&lt;42; i++) HoyahCalendar.a[i/7][i%7] = ""; } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload