我不确定要搜索什么,我尝试了一些但没有找到我需要的东西。基本上我的应用程序的默认图像是在imageview中显示的徽标。我有“admin”活动,用户可以进一步自定义应用程序。我如何允许他们从我的默认徽标更改为他们选择的徽标并在主要活动的相同图像视图中显示(与他们选择的位置,管理活动不同)?
非常感谢!
答案 0 :(得分:2)
点击按钮,我们将触发以下代码:
@Override
public void onClick(View v) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
}
On ActivityResult:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
try {
String path = "";
if (requestCode == 1) {
if (resultCode == RESULT_OK) {
Uri imageUri = data.getData();
Log.d("image selected path", imageUri.getPath());
System.out.println("image selected path"
+ imageUri.getPath());
path = getRealPathFromURI(EditProfileMemberActivity.this,
imageUri);
}
//DO other stuff
}
} catch (Exception e) {
System.out.println(e);
}
}