Skip to content Skip to sidebar Skip to footer

Android Studio - Tabhost Refresh Tab Content

please help me.. ok here is my problem. i use tabhost and i have 3 tabs. compose of SONG LIST, NEW SONGS and FAVORITES here is the code of the tabhost.. @Override public View o

Solution 1:

In your second tabs new Song Override this method if you are using fragment.

@Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if(isVisibleToUser){
          displayPlayer1NewListView() ;
        }
    }

This method is call when your 2nd tabs fragment is visible on screen and refresh this list.

Solution 2:

for those who encounter this problem.. i found an answer..

host.setOnTabChangedListener(newTabHost.OnTabChangeListener() {
            @OverridepublicvoidonTabChanged(String tabId) {

                int i = host.getCurrentTab();
                if (i == 0) {
                    displayPlayer1ListView();
                } elseif (i == 1) {
                    displayPlayer1NewListView();
                }
            }
        });

Post a Comment for "Android Studio - Tabhost Refresh Tab Content"