我在一个活动上有很多按钮,它们都使用以下代码调用相同的活动
startActivityForResult()
结果被捕获
void onActivityResult(int requestCode, int resultCode, Intent data)
.
我如何知道按钮返回结果?
我在一个活动上有很多按钮,它们都使用以下代码调用相同的活动
startActivityForResult()
结果被捕获
void onActivityResult(int requestCode, int resultCode, Intent data)
.
我如何知道按钮返回结果?
change requestCode
for every Button
. You can use, for instance, as RequestCode
the id of the button
. When onActivityResult is called,
void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode) {
case R.id.button1:
break;
}
}
you can switch on requestCode
, ad case for the buttonId