onActivityResult 通过case对不同情况进行处理

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (resultCode) {
case 10:
Toast.makeText(getActivity(),"haha",Toast.LENGTH_SHORT);
Bundle a = data.getExtras();
String url = a.getString("picture");
String alterusername = a.getString("username");
Bitmap bm = BitmapFactory.decodeFile(url);
avatarImg.setImageBitmap(bm);
UserNameTextView.setText(alterusername);
break;
case 1:
Bundle b = data.getExtras();
String index = b.getString("servicepointname");
UserFuWuTextView.setText(index);//设置服务范围的显示TextView
break;
case 20:
Bundle c = data.getExtras();
String username = c.getString("UserName");
String userphone = c.getString("UserPhone");
UserPhoneTextView.setText(userphone);
UserNameTextView.setText(username);
break;
}

super.onActivityResult(requestCode, resultCode, data);
}
posted @ 2016-02-23 18:25  Wei_java  阅读(322)  评论(0编辑  收藏  举报