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 9019121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:42:03+00:00 2026-06-16T04:42:03+00:00

I work to an application in android and I had one situation that I

  • 0

I work to an application in android and I had one situation that I can’t figure out what is happening. The app is with 3 tabs, created with Fragments and TabHost and every tab have a list of articles with specific content.

I have a listview inside the last tab. The listview is created with listAdapter and is populated from a drupal view. Everything works perfect, but when I change tab and come back to the initial tab, items of listview repeats.

The code of tab content is:

   httpconnect httpcon = new httpconnect();   
   ArrayList<HashMap<String, String>> articleList = new ArrayList<HashMap<String, String>>();  
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          if (container == null) { 
             return null;
          } 
             View v = inflater.inflate(R.layout.recomandate, container, false);   
             list=(ListView) v.findViewById(R.id.list); 
             infoGet();  
             return v;  
    }


    public void infoGet() { 
            try {   
                JSONArray jArray = new JSONArray(httpcon.connectareHttp(url));  

           for(int i=0; i<jArray.length(); i++) { 
               HashMap<String, String> map = new HashMap<String, String>();
             JSONObject json = jArray.getJSONObject(i);             

                String id; 
                   id = json.getString("nid"); 
                    map.put(KEY_ID, id);  

                 String articleTitle; 
                  articleTitle= json.getString("title"); 
                    map.put(KEY_TITLE, articleTitle);

                  String content; 
                    content= json.getString("body"); 
                      map.put(KEY_BODY, content);

                   String img; 
                     img = json.getString("field_image"); 
                       map.put(KEY_THUMB_URL, img); 

                  articleList.add(map);  
           }

                adapter = new ListAdapter(getActivity(), articleList);  
                  list.setAdapter(adapter);  

        }   catch (Exception e) {

                    Log.e("log_tag", "Error Parsing Data "+e.toString());
                    } 

    }

How can I make not to repeate items from listview when I change between tabs?

Thanks in advance for help!

Regards, Cosso!

  • 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-16T04:42:04+00:00Added an answer on June 16, 2026 at 4:42 am

    your answer is here:

             articleList.add(map);  
    

    you keep re-adding every time the items.

    When you call .replace() in a FragmentTransaction, you’re not re instantiating the fragment object but the FragmentManger is asking the fragment to createView() every time to make sure it will fit and layout properly on the ViewGroup.

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

Sidebar

Related Questions

maybe you can help me out. I'm working on an Android app project that
I'm trying to get the browser function in my Android application to work but
I am working in an android application and I want to work fetch details
java.lang.SecurityException: Selected service does not require android.permission.BIND_WALLPAPER So this does work: <application android:icon=@drawable/icon android:label=Wallpaper
I have problem with my Android application. I need an application that will send
I am developing an Android Application and I have an Activity that looks like
I had worked on an Android application with 2.2 at the beginning. It works
I am writing an Android application that uses some functionality that has been published
I'm working on an Android application that will send MMS internally without using the
I have successfully implemented a client/server Android GCM application. My app server holds a

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.