写一个方法如下:
public String getOurSelWeek(int sel) { Date date = null; String[] weekDaysName = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"}; SimpleDateFormat df = new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); calendar.roll(Calendar.DAY_OF_YEAR, sel); String str = df.format(calendar.getTime()); try { date = df.parse(str); } catch (ParseException e) { e.PRintStackTrace(); } calendar.setTime(date); int intWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1; return weekDaysName[intWeek]; }然后在需要展示的布局处 调用该方法
tv_week.setText(xxxActivity.this.getOurSelWeek(1));
设置成功之后即能显示
新闻热点
疑难解答