how to start week from sunday instead of current date
below is my code which show current week next week and previous week
problem is when current wek is 37 when click on nextweek is first show 36
then show 37 and then week 38 39 40 same as for last week if current week
s 37 when click on next week button is first show 38 then 37 36... also my
calendar start week form current date i want to show from sunday what do i
do?
Button last_week;
Button next_week;
static Button e00;
static Button e01;
static Button e02;
static Button e03;
static Button e04;
static Button e05;
static Button e06;
int next = 1;
int currentweekno;
static TextView txt1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e00 = (Button) findViewById(R.id.e00);
e01 = (Button) findViewById(R.id.e01);
e02 = (Button) findViewById(R.id.e02);
e03 = (Button) findViewById(R.id.e03);
e04 = (Button) findViewById(R.id.e04);
e05 = (Button) findViewById(R.id.e05);
e06 = (Button) findViewById(R.id.e06);
// e00 = Sun;
// e01 = Mon;
// e02 = Tues;
// e03 = Wed;
// e04 = thur;
// e05 = Fri;
// e06 = Sat;
last_week = (Button) findViewById(R.id.last_week);
next_week = (Button) findViewById(R.id.next_week);
Calendar mCalendar = Calendar.getInstance();
currentweekno = mCalendar.get(Calendar.WEEK_OF_YEAR);
Log.d("Current Week:", "" + mCalendar.get(Calendar.WEEK_OF_YEAR));
last_week.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
weekOfGivenMonth(currentweekno--);
}
});
next_week.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
weekOfGivenMonth(currentweekno++);
}
});
weekOfGivenMonth(currentweekno++);
}
private static void weekOfGivenMonth(int weekNext) {
String val;
val=String.valueOf(weekNext);
Calendar c = Calendar.getInstance();
c.set(Calendar.WEEK_OF_YEAR, weekNext);
String[] days = new String[7];
DateFormat df = new SimpleDateFormat("EEE dd/MM/yyyy");
for (int i = 0; i < 7; i++) {
Log.d("DATEA TAG",df.format(c.getTime()));
c.add(Calendar.DATE, 1);
}
}
No comments:
Post a Comment