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

  • Home
  • SEARCH
  • 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 7562275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:22:35+00:00 2026-05-30T13:22:35+00:00

I have string array which is fetched from an external xml response. This string

  • 0

I have string array which is fetched from an external xml response. This string array can be presented in a listview. I want to append a string array with new xml data and add it to the listview everytime the user reaches the end element of string array in the listview. How can I achieve this? I’ve researched a lot on this topic.I could hardly find any examples related to this context. Any help will be much appreciated. Thank you.

  ArrayList<String> get_msgList =MsgHandler.getMsgsList();
String[] msgList=new String[get_msgList.size()];
msgList=get_msgList.toArray(msgList);

 ArrayAdapter<String> adapter = new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1, get_msgList );
myListView.setAdapter(adapter);

This is how I get my string array and add it to the listview.

  • 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-05-30T13:22:36+00:00Added an answer on May 30, 2026 at 1:22 pm

    — Update, after looking more into documentation I think you still could use ArrayAdapter —

    So if you look at the documentation for listview you see

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string-array name="countries_array">
            <item>Bahrain</item>
            <item>Bangladesh</item>
            <item>Barbados</item>
            <item>Belarus</item>
            <item>Belgium</item>
            <item>Belize</item>
            <item>Benin</item>
        </string-array>
    </resources>
    

    and to load those you use:

    setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, countries));
    

    The problem here is you have to deal with figuring out when they get to the end of the list and how to load more data without blocking the UI.

    Thus, to save yourself a lot of headache, I recommend using Commonsware Endless Adapter
    Do so like this:

    import android.app.ListActivity;
    import android.os.Bundle;
    import android.os.SystemClock;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ArrayAdapter;
    import com.commonsware.cwac.endless.EndlessAdapter;
    import java.util.ArrayList;
    
    public class YourListActivity extends ListActivity {
      @Override
      public void onCreate(Bundle state) {
        super.onCreate(state);
        setContentView(R.layout.main);
        String[] countries = getResources().getStringArray(R.array.countries_array);
        setListAdapter(new YourAdapter(countries));
      }
    
      class YourAdapter extends EndlessAdapter {
    
    
        public YourAdapter(String[] list) {
          super(new ArrayAdapter<String>(YourAdapter.this,
                                          R.layout.row,
                                          android.R.id.text1,
                                          list));
        }
    
        @Override
        protected View getPendingView(ViewGroup parent) {
          View row=getLayoutInflater().inflate(R.layout.row, null);      
          return row.findViewById(android.R.id.text1);      
        }
    
        @Override
        protected boolean cacheInBackground() {
          SystemClock.sleep(10000);       // pretend to do work
          //put logic here to fetch the data
          //this happens in the background so you can't do anything with the UI
          //return whether or not you have more data, true if you do false otherwise.
          boolean haveMoreData = true;//this up to you to figure out
          return haveMoreData;
        }
    
        @Override
        protected void appendCachedData() {
            //here is where you do the work to actually add the data obtained in cacheInBackground to the ArrayAdapter
            ArrayAdapter<String> a=(ArrayAdapter<String>)getWrappedAdapter();        
            for (int i=0;i<25;i++) { 
               a.add(a.getCount()); 
            }
          }
        }
      }
    }
    

    here is another question that looks similar to your own on here:
    Android Endless List

    — Update: How to add multiple string arrays to an adapter —
    There are multiple ways to do this, the most simple way would probably be to use the adapters add method..

    Look at this: http://developer.android.com/reference/android/widget/ArrayAdapter.html
    and see the method add.
    Currently you have a variable named adapter:

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, get_msgList);
    

    Whenever you want to add more data to that adapter just call:

      adapter.add("Some new data");
    

    So if you had another String[] array of data and you wanted to add all of it to the current adapter, just use:

       String[] someNewData = getStringArray();//no idea how you are getting the array, this is just an example
       for (String s : someNewData) {
          adapter.add(s);
        }
    

    After you’ve added the new data you may need to call adapter.notifyDataSetChanged but I’m not sure (it may happen for you).. I would try it first without it and see if everything works as expected and if not add it.

    Now one thing you will probably want to do is either make the adapter variable an instance variable of your class so you can use it anywhere in the class.

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

Sidebar

Related Questions

I have the following code which fetches a string from an array of strings
i have an string data array which contains data like this 5~kiran 2~ram 1~arun
I have a String array which I want to convert to specifc format. For
I have a String Array which is contain dates that read from a CSV
Thanks in advance... i have a string array which i want to set in
I have a string array variable called 'myAttachmentArray[]' which holds different figures like this:
i have a String Array which comes from a splitted String string[] newName= oldName.Split('\\');
I have a string say string s =C:\\Data , I have an array which
I have a .NET string which is Base64 encoded representation of an array of
I have an array of strings in python which each string in the array

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.