private void updateUserInfo() { mUserNameView.setText(mUserInfo.getName()); mHeaderPicView.setImageUrl(mUserInfo.getProtrait(), getImageLoder()); Integer post = 0; // TODO 获取文章数 mPostsView.setText(String.valueOf(post)); Integer goods = 0; // TODO 获取赞数 mGoodsView.setText(String.valueOf(goods)); String age = new String(); try { Date birthday = new SimpleDateFormat("yyyy-MM-dd").parse(mUserInfo.getBirthday()); Calendar ca = Calendar.getInstance(); ca.setTime(birthday); int birthYear = ca.get(Calendar.YEAR); ca.setTime(new Date()); int currentYear = ca.get(Calendar.YEAR); age = String.valueOf(currentYear - birthYear); } catch (Exception e) { } mAgeView.setText(age); mCityView.setText(mUserService.loadPlaceName(mUserInfo.getCity())); mDescriptionView.setText(mUserInfo.getDescription()); mSexIconView.setImageResource(UserService.SEX_DRAWABLE_MAP.get(mUserInfo.getSex())); }
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.activity_personalinfo); mUserService = getServiceManager().getUserService(); mHeaderPicView = (LoadImageView) findViewById(R.id.personalinfo_headerpic); mUserNameView = (TextView) findViewById(R.id.personalinfo_username); mPostsView = (TextView) findViewById(R.id.personalinfo_posts); mGoodsView = (TextView) findViewById(R.id.personalinfo_goods); mAgeView = (TextView) findViewById(R.id.personalinfo_age); mCityView = (TextView) findViewById(R.id.personalinfo_city); mDescriptionView = (TextView) findViewById(R.id.personalinfo_description); mSexIconView = (ImageView) findViewById(R.id.personalinfo_icon_sex); mHeaderPicView.setOnClickListener(this); findViewById(R.id.personalinfo_item_age).setOnClickListener(this); findViewById(R.id.personalinfo_item_city).setOnClickListener(this); findViewById(R.id.personalinfo_item_description).setOnClickListener(this); findViewById(R.id.personalinfo_item_sex).setOnClickListener(this); }