开发者

How to specify onActivityResult() for 2 views?

I have 3 views in my application. My first view (FIRST_VIEW) has 2 buttons (BTN_2 and BTN_3). Each button will start seperate views, means BTN_2 causes to start SECON开发者_开发问答D_VIEW and BTN_3 will start THIRD_VIEW. In my FIRST_VIEW i have one onActivityResult() function. How can I set two onActivityResult() functions for each button result (that is from SECOND_VIEW and from THIRD_VIEW)? How can I specify that onActivityResult() function for each view? Please Help me..... Thank you..


There is only one onActivityResult. You need to to check the resultCode and requestCode for actually identifying the activity.

startActivityForResult(intentSecond, 1002);
startActivityForResult(intentThird, 1003);
@override
void onActivityResult(int requestCode, int resultCode, Intent data) {
  if(requestCode==1002) //it was Second Activity
  else if(requestCode==1003) //it was Third Activity
}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜