0

我正在使用日历应用程序我正在检查 button.get 文本是否等于当前日期更改是颜色 toxxx 其他方式以黑色显示文本但问题是按钮文本将显示相同的颜色值是否为当前日期?

今天看到这张图片是 7 月 29 日

http://imgur.com/8fpjSaA

当我点击前一周时,29 将是第二个按钮显示为粉红色的鞋子再次显示粉红色的第二个按钮值,请参阅此

http://imgur.com/YkbE8AS

public class HoyahCalendar extends Activity {

    public static String[][] a = new String[6][7];
    String  January="January";
    String  February="February";
    String  March="March";
    String  April="April";
    String  May="May";
    String  June="June";
    String  Jully="Jully";
    String  August="August";
    String  September="September";
    String  October="October";
    String  November="November";
    String  December="December";
    String  Monthname;


    Button e00;
    Button e01;
    Button e02;
    Button e03;
    Button e04;
    Button e05;
    Button e06;

    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]);

        if(e00.getText().toString().equals(String.valueOf(mDay)))
        // if(e00.getText().toString().equals(mDay))
        {
            e00.setTextColor(Color.parseColor("#FFBBFF"));
            Toast.makeText(this, "Button1 text equals!", Toast.LENGTH_SHORT).show();
        }
        e01.setText("" + a[0][3]);

        if(e01.getText().toString().equals(String.valueOf(mDay)))
        {
            e01.setTextColor(Color.parseColor("#FFBBFF"));
            Toast.makeText(this, "Button2 text equals!", Toast.LENGTH_SHORT).show();
        }

        e02.setText("" + a[0][2]);
        if(e02.getText().toString().equals(String.valueOf(mDay)))
        {
            e02.setTextColor(Color.parseColor("#FFBBFF"));
            Toast.makeText(this, "Button3 text equals!", Toast.LENGTH_SHORT).show();
        }
        else
        {
            e02.setTextColor(Color.parseColor("#000000"));
        }

        e03.setText("" + a[0][3]);
        if(Integer.parseInt(e03.getText().toString()) == mDay)
        {
            e03.setTextColor(Color.parseColor("#FFBBFF"));
            Toast.makeText(this, "Button4 text equals!", Toast.LENGTH_SHORT).show();
        }

        e04.setText("" + a[0][4]);
        if(e04.getText().toString().equals(String.valueOf(mDay)))
        {
            e04.setTextColor(Color.parseColor("#FFBBFF"));
            Toast.makeText(this, "Button5 text equals!", Toast.LENGTH_SHORT).show();
        }

        e05.setText("" + a[0][5]);
        if(e05.getText().toString().equals(String.valueOf(mDay)))
        {
            e05.setTextColor(Color.parseColor("#FFBBFF"));
            Toast.makeText(this, "Button6 text equals!", Toast.LENGTH_SHORT).show();
        }

        e06.setText("" + a[0][6]);
        if(e06.getText().toString().equals(String.valueOf(mDay)))
        {
            e06.setTextColor(Color.parseColor("#FFBBFF"));
            Toast.makeText(this, "Button7 text equals!", Toast.LENGTH_SHORT).show();
        }
    }


    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<week_no;i++)
            HoyahCalendar.a[i/7][i%7] = "";

        for(i=week_no; i<week_no + month_days; i++) {
            s = i - week_no + 1;
            HoyahCalendar.a[i/7][i%7] = String.valueOf(s);
            if (s == currentDay && HoyahCalendar.currentIndex == -1) {
                HoyahCalendar.currentIndex = i/7;
            }
        }

        for (i=0; i<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<42; i++)
            HoyahCalendar.a[i/7][i%7] = "";
    }
}
4

1 回答 1

0

如果不是当天,您必须将颜色重置为黑色。

因此,对于每个“如果”,您必须添加一个“其他”,将颜色设置为黑色。

于 2013-07-29T06:31:16.860 回答