Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8917367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:28:01+00:00 2026-06-15T05:28:01+00:00

I’m new in Android and I’m implementing a small project in which, I have

  • 0

I’m new in Android and I’m implementing a small project in which, I have news from one Drupal website. This app is with 3 tabs and every tab have a list of articles with specific content. The list of articles is created by textviews and imageviews arranged in linearlayout. When I click on the title, the article is opening with details. Those articles are loaded from Drupal site throught HTTP POST and ViewJSON module. Tabs are created with FragmentActivity and TabHost. Everything’s ok and works fine until here.

My problem is that I want to make one refresh button, to be placed over tabs and when I press it, the list of articles must refresh or reload and keep the current tab opened.
I tried to replace tab fragment content and re-open it, but when I click on the title of one article to open it, the tab content remain in stack under all fragments. I mention that when I click on article’s title, one new fragment is opening. I sent an id of the articles as an argument and in the same fragment I open the article’s content.

I was trying with this code but no success.

Button btn_refresh = (Button) findViewById(R.id.btn_refresh);
btn_refresh.setOnClickListener(new View.OnClickListener() {     
    public void onClick(View v) {
       String current_tab = mTabHost.getCurrentTabTag(); 
       if(current_tab.contains("POPULARE")){                
         Fragment f;
         f = new PopulareActivity(); 
         FragmentTransaction ft =   getSupportFragmentManager().beginTransaction(); 
         ft.replace(R.id.tot,f);               
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 
         ft.commit();
       }
       if(current_tab.contains("RECOMANDATE")){           
         Fragment f;
         f = new RecomandateActivity(); 
         FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); 
         ft.replace(R.id.tot,f);   
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 
                     ft.commit(); 
       }
   } 
});

More exactly I enter on app, press Tab2 (show the list of articles from tab2), press refresh button, open one article, press the back button of mobile device and show me the content of tab2. Now, I enter on tab1 (and show the list of articles from tab1), open one article from the list of tab1, show me what I need, and press the back button from mobile. In this moment is shown the tab2 content (the list of articles form tab2 from where I pressed the refresh button.).

To open details of an article I use:

tv.setOnClickListener(new View.OnClickListener() { 
  public void onClick(View v) {                          
    Fragment f;
    f = new DetaliiActivity();
    Bundle data = new Bundle();  
    data.putInt("id", nid);
    f.setArguments(data);
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.replace(R.id.tot,f);                     
    ft.addToBackStack(null);                         
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); 
    ft.commit(); 
  }
});

Thanks in advance for help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:28:02+00:00Added an answer on June 15, 2026 at 5:28 am

    To refresh the contents of a fragment, you could keep a reference to the fragment, and call a public (for example) refresh() method in that fragment. Example:

    public class ArticleTabFragmentActivity extends FragmentActivity{
      private PopulareFragment populareFragment;
      private RecomandateFragment recomandateFragment;
    
      <code>
    
      private void bindView(){
        Button btn_refresh = (Button) findViewById(R.id.btn_refresh);
    
        btn_refresh.setOnClickListener(new View.OnClickListener() {
    
                public void onClick(View v) {
                     String current_tab = mTabHost.getCurrentTabTag(); 
                     if(current_tab.contains("POPULARE")){
                       populareFragment.refresh();
                     } else if(current_tab.contains("RECOMANDATE")){
                       recomandateFragment.refresh();
                     } 
        });
      }
    
    
    
    }
    
    public class PopulareFragment extends Fragment{  
    
      public void refresh(){
        <refresh the contents of the fragment>
      }
    
    }
    
    <Same for other fragment>
    

    Now when you create the tab fragment, like the PupulareFragment, use the pupulareFragment instance variable to store the fragment. So it is available in the refresh button onClick method.

    This way you are not replacing/creating any new fragments when refreshing. So going back to tabActivity after going to de article details activity, would probably work fine aswell.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.