Solution in Android, when using Tabhost, if the tab is clicked, the activity of the tab is loaded, and the activity is not created again when you switch back from another tab (OnCreate), So to refresh activity every time you click on the tab, here's how: Method 1 Adds the object to be refreshed to Onresume 1 @Override 2 public void Onresume () {3 Super.onresume (); 4//Code 5} Each time the tab is toggled, the activity calls the secondary method Onresume method But there is a problem with this method, if the next activity is loaded in this method, here we are named Activity2. When the Activity2 is finished, the finish () method is called, and the activity corresponding to tab is still executing the Onresume () method to refresh the data again. If you want to avoid this situation, use the method 2:tabhost.addtab (tabhost.newtabspec (0 + "). Setindicator (TV1). SetContent (New Intent (This, Newsactivity.class). Addflags (Intent.flag_activity_clear_top)); Tabhost.addtab (Tabhost.newtabspec (1 + "). Setindicator (TV2). SetContent (New Intent (this, videoactivity.class). Addflags (Intent.flag_activity_clear_top)); Use the. Addflags (intent.flag_activity_clear_top) to do it.
Android Tabhost data not refreshed when switching activity