Sharing data between tabs

后端 未结 2 889
走了就别回头了
走了就别回头了 2020-12-05 22:19

I am getting some glitches while making a tab enabled application.
I want to share data, between two tabs of my application. How can I achieve the same?

Rgds Rob

2条回答
  •  佛祖请我去吃肉
    2020-12-05 23:09

    the correct way is setting a static field into the activity that creates the tabs

     public class greformanews extends TabActivity {
    
           public static String JorgesysTitle;
    ...
    ...
    ...
    

    so in your Activity defined in tab 1

     @Override
     protected void onPause() { 
        greformanews.JorgesysTitle = "JORGESYS =)";
     super.onPause();
    }
    

    in your Activity defined in tab 2

    //get  value defined in Activity 1 !:)
    String Title =  greformanews.JorgesysTitle
    

提交回复
热议问题