[英]Start activity for result not work, between different activities
I have the main page where the photo is loaded, depending on what the array on the other page contains, in order to synchronize them I used StartActivityForResult();.我有加载照片的主页,具体取决于其他页面上的数组包含的内容,为了同步它们,我使用了 StartActivityForResult();。
It will works like this: MainActivity has a photo, i press showMore button(open showMoreActivity), at showMoreActivity change text and after i finish showMoreActivity, MainActivity load the new photo depends on new text, but real it doesn`t change photo.它将像这样工作:MainActivity 有一张照片,我按下 showMore 按钮(打开 showMoreActivity),在 showMoreActivity 更改文本,在我完成 showMoreActivity 后,MainActivity 加载新照片取决于新文本,但实际上它不会更改照片。
Can you help me?你能帮助我吗? Where the mistake is?
错误在哪里?
buttonShowMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), ShowMore.class);
onStop();
getActivity().startActivityForResult(intent, 1);
}
});
onClick button ShowMore Listener onClick按钮 ShowMore Listener
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data == null) {return;}
String dataStringExtra =data.getStringExtra("name1");
Picasso.get().load( dataStringExtra + ".jpg").into(imageViewFirstOfCurrentList);
}
onActivityResult method onActivityResult 方法
Intent intent = new Intent();
intent.putExtra("name1", List.get(0).toString());
setResult(RESULT_OK, intent);
finish();
when close showMore Activity关闭时显示更多活动
try removing call to onStop() in your onClick() method尝试在 onClick() 方法中删除对 onStop() 的调用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.