How to setResult() for a TabActivity which contains activity for tabs

拈花ヽ惹草 提交于 2019-12-22 18:50:16

问题


My TabActivity contains two tabs which calls two two different activities . I want to setResult() for the TabActivity when either one of the child finishes.

Is there any method to find out when my activity inside tab finishes ?

Thank you -Eby


回答1:


I found another way

`   @Override
    public void finishFromChild(Activity child)
    {
        setResult(REFRESH);
        super.finishFromChild(child);
    }
`

finsihFromChild will let us know when the child activity is finishing!! @pentium10 thank you very much for your suggestion..




回答2:


Ok i've got an even easier method to pass the result:

in your child activity do this

Intent list = this.getIntent();
list.setAction(Integer.toString(RESULT_CODE_TO_PASS));
finish();

and then in the parent do this:

@Override 
public void finishFromChild(Activity child) { 

        Intent test = child.getIntent();
        setResult(new Integer(test.getAction()));
        super.finishFromChild(child); 
        } 



回答3:


You need to issue a Broadcast from your child activity(when finished) and implement the BroadcastReceiver on the class you want to catch the broadcast. You can use the extras to transfer data from one activity to another.



来源:https://stackoverflow.com/questions/3369423/how-to-setresult-for-a-tabactivity-which-contains-activity-for-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!