Sharing data between tabs

后端 未结 2 874
走了就别回头了
走了就别回头了 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:00

    You need to use intents to different activities, or in that case of tabs.

    Go to Android Common Tasks

    And look at the subject below "some intent examples". This will get you started.

    You basically need to put whatever values you want into a bundle and pass that over to the new activity using intent.putextras();

    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题