在按鈕的Click事件,調用此函數
private void showImageChooser(){
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(pickIntent, "Select Image");
startActivityForResult(chooserIntent, 500);
}
在OnActivityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 500 && resultCode == RESULT_OK && data != null){
imageFile = data.getData();
Glide.with(getApplicationContext()).load(imageFile).into(profilePic);
}
}
請使用您的ImageView到位profilePic的。
請發佈錯誤日誌 –
錯誤是什麼? SELECT_PICTURE是一個請求代碼,你給它有什麼價值嗎?究竟是什麼錯誤? – Sahil