/** 更新显示界面 */ private void updateView() { try { String teachDate = null; String week = null; tvName.setText(studentBean.getChild().getName()); if (currentCourse != null) { String strBT = currentCourse.getTeachTime().get(0).get("beginTime"); String strET = currentCourse.getTeachTime().get(0).get("endTime"); week = currentCourse.getTeachTime().get(0).get("week"); tvToTime.setText(strET.substring(0, strET.lastIndexOf(":"))); tvFromTime.setText(strBT.substring(0, strBT.lastIndexOf(":"))); teachDate = currentCourse.getTeachDate(); tvClassName.setText(currentCourse.getName()); } else { teachDate = DateUtil.datetimeToString(new Date(), "yyyy-MM-dd"); week = DateUtil.datetimeToString(new Date(), "EEEE"); } ToastUtil.log(TAG, teachDate + " " + week); tvClassInfo.setText( "今天 " + teachDate .replace("-", ".") .substring(teachDate.indexOf("-") + 1, teachDate.length()) + " " + week); } catch (Exception e) { ToastUtil.printErr(e); } }
private void init() { lvCourses = (ListView) view.findViewById(R.id.index_last_info_lv_courses); rlLatestInfo = (RelativeLayout) view.findViewById(R.id.index_last_info_rl_latest_info); llClassTime = (LinearLayout) view.findViewById(R.id.index_last_info_ll_class_time); llClassName = (LinearLayout) view.findViewById(R.id.index_last_info_ll_class_name); llNoCourse = (LinearLayout) view.findViewById(R.id.index_last_info_ll_no_course); tvName = (TextView) view.findViewById(R.id.index_last_info_tv_name); tvClassInfo = (TextView) view.findViewById(R.id.index_last_info_tv_class_info); tvToTime = (TextView) view.findViewById(R.id.index_last_info_tv_to_time); tvFromTime = (TextView) view.findViewById(R.id.index_last_info_tv_from_time); tvClassName = (TextView) view.findViewById(R.id.index_last_info_tv_class_name); IvEnter = (ImageView) view.findViewById(R.id.index_last_info_iv_enter); adapter = new IndexLastInfoAdapter(); lvCourses.setAdapter(adapter); List<HMCourseBean> cs = studentBean.getCourses(); if (cs != null && cs.size() > 0) { cleanData(cs); if (currentCourse != null) { rlLatestInfo.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Bundle bundle = new Bundle(); bundle.putString(HMCourseDetailAct.BUNDLE_KEY, currentCourse.getId()); bundle.putString("courseName", currentCourse.getName()); HMNavUtil.goToNewAct(context, HMCourseDetailAct.class, bundle); } }); } else { llNoCourse.setVisibility(View.VISIBLE); llClassName.setVisibility(View.GONE); llClassTime.setVisibility(View.GONE); IvEnter.setVisibility(View.GONE); } } else { llNoCourse.setVisibility(View.VISIBLE); llClassName.setVisibility(View.GONE); llClassTime.setVisibility(View.GONE); IvEnter.setVisibility(View.GONE); } }