// 更新用户显示信息 public void updateUserData() { // 提取当前登陆用户的信息 MyApplication myApplication = (MyApplication) getActivity().getApplication(); User user = myApplication.getUser(); Log.w("user is null?", (user == null) ? "is" : "no"); // 头像 headView = (RoundImageView) rootLayout.findViewById(R.id.left_user_head); Log.w("head", user.getHead()); headView.setImageBitmap( BitmapFactory.decodeFile(DataVar.APP_IMG_FILE + File.separator + user.getHead())); // 昵称 tvNickName = (TextView) rootLayout.findViewById(R.id.left_user_nickname); tvNickName.setText(user.getNickName()); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootLayout = inflater.inflate(R.layout.frag_left, null); // 所有选项 View mainView = rootLayout.findViewById(R.id.tvMain); View bookCategoryView = rootLayout.findViewById(R.id.tvBookCategory); View robotView = rootLayout.findViewById(R.id.head_robot); View accountView = rootLayout.findViewById(R.id.tvAccount); View settingsView = rootLayout.findViewById(R.id.tvSettings); View aboutView = rootLayout.findViewById(R.id.tvAbout); // 提取当前登陆用户的信息 MyApplication myApplication = (MyApplication) getActivity().getApplication(); User user = myApplication.getUser(); Log.w("user is null?", (user == null) ? "is" : "no"); // 头像 headView = (RoundImageView) rootLayout.findViewById(R.id.left_user_head); Log.w("head", user.getHead()); headView.setImageBitmap( BitmapFactory.decodeFile(DataVar.APP_IMG_FILE + File.separator + user.getHead())); headView.setOnClickListener(this); // 昵称 tvNickName = (TextView) rootLayout.findViewById(R.id.left_user_nickname); tvNickName.setText(user.getNickName()); mainView.setOnClickListener(this); bookCategoryView.setOnClickListener(this); robotView.setOnClickListener(this); accountView.setOnClickListener(this); settingsView.setOnClickListener(this); aboutView.setOnClickListener(this); Log.w("test", "leftFragmentonCreateView"); return rootLayout; }