现在我在recyclerview的图像更改方面遇到问题。
这是我的活动Java代码
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(photo_upload_Activity.this);
View view = LayoutInflater.from(photo_upload_Activity.this).inflate(R.layout.edit_box, null, false);
builder.setView(view);
btn_upload = view.findViewById(R.id.btn_upload1);
edit_photo_title = view.findViewById(R.id.edit_photo_title);
edit_phto_content = view.findViewById(R.id.edit_photo_content);
final AlertDialog dialog = builder.create();
btn_upload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, 1);
title = edit_photo_title.getText().toString();
content = edit_phto_content.getText().toString();
dialog.dismiss();
}
});
dialog.show();
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case 1:
imageUri = data.getData();
photolist.add(new photoInfo(imageUri, "Title : " + title, "Content : " + content));
try {
myAdpayer = new photoAdapter(photo_upload_Activity.this, photolist);
mRecycler.setAdapter(myAdpayer);
//img_upload_picture.setImageURI(imageUri);
} catch (Exception e) {
e.printStackTrace();
}
}
}
这是适配器代码的一部分
PopupMenu.OnMenuItemClickListener popupClick = new PopupMenu.OnMenuItemClickListener() {// 사진올린후 수정 버튼 눌릴시
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu3:
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
mActivity.startActivityForResult(intent, 1);
这里有问题
我想从开关处的图库中更改图像-> case R.id.menu3;但我无法覆盖onActivitiyResult方法,因此无法访问图库
如何在Adapter Java文件中调用onActivityResult方法?
对不起我的英语不好.. T ^ T