-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.java
More file actions
50 lines (41 loc) · 1.78 KB
/
MainActivity.java
File metadata and controls
50 lines (41 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.example.user.timetable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity {
TextView mon, tue, wed, thu, fri;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Calendar oCalendar = Calendar.getInstance( );//day check
mon = (TextView)findViewById(R.id.mon);
tue = (TextView)findViewById(R.id.tue);
wed = (TextView)findViewById(R.id.wed);
thu = (TextView)findViewById(R.id.thu);
fri = (TextView)findViewById(R.id.fri);
if(oCalendar.get(Calendar.DAY_OF_WEEK) == 2)//if today is monday, monday TextView is changing color
{
mon.setBackgroundResource(R.color.colorAccent);
}
else if(oCalendar.get(Calendar.DAY_OF_WEEK) == 3)//if today is tuesday, monday TextView is changing color
{
tue.setBackgroundResource(R.color.colorAccent);
}
else if(oCalendar.get(Calendar.DAY_OF_WEEK) == 4)//if today is wednesday, monday TextView is changing color
{
wed.setBackgroundResource(R.color.colorAccent);
}
else if(oCalendar.get(Calendar.DAY_OF_WEEK) == 5)//if today is thursday, monday TextView is changing color
{
thu.setBackgroundResource(R.color.colorAccent);
}
else if(oCalendar.get(Calendar.DAY_OF_WEEK) == 6)//if today is friday, monday TextView is changing color
{
fri.setBackgroundResource(R.color.colorAccent);
}
}
}