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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:01:00+00:00 2026-05-23T07:01:00+00:00

I want to combine two ArrayList into a single one. My first arraylist looks

  • 0

I want to combine two ArrayList into a single one.

My first arraylist looks like this:

{a,s,d,f,g,h,......}

My second arraylist looks like this:

{z,x,c,v,b,.....}

Then I want to combine both to be as

  {a,s,d,f,g,h,.....,z,x,c,v,b.....}

First List is

ArrayList<String> firstname1   = new ArrayList<String>();

Where as the second list is as

ArrayList<String> first   = new ArrayList<String>();

Now I want to combine all this together and I want it to be listed out in list view.
How to do this?

  • 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-23T07:01:01+00:00Added an answer on May 23, 2026 at 7:01 am

    Combine two ArrayList into a single one

    firstname1.addAll(first);
    

    Please refer this article for sample code to concat two lists.

    How to show these items in list view :

    your layout should be ( as I used main.xml)

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginTop="0dip"
    android:background="@android:color/transparent">
        <ListView
                android:id="@+id/custom_list_view"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:cacheColorHint="#00000000"
                android:fastScrollEnabled="true"
                android:background="@android:color/transparent"
                android:fadeScrollbars="true"
                android:layout_gravity="top"
                android:padding="2dp">
        </ListView>
    </LinearLayout> 
    

    and now Activity as CustomListView.java

    public class CustomListView extends Activity {
    
        ArrayList<String> firstname1;
        ArrayList<String> first;
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            firstname1 = new ArrayList<String>();
            first = new ArrayList<String>();
            //Let both array list having some data
    
            firstname1.add("firstname1_data1");
            firstname1.add("firstname1_data2");
            firstname1.add("firstname1_data3");
            firstname1.add("firstname1_data4");
            firstname1.add("firstname1_data5");
            firstname1.add("firstname1_data6");
            firstname1.add("firstname1_data7");
            firstname1.add("firstname1_data8");
            firstname1.add("firstname1_data9");
            firstname1.add("firstname1_data10");
    
            first.add("first_data1");
            first.add("first_data2");
            first.add("first_data3");
            first.add("first_data4");
            first.add("first_data5");
            first.add("first_data6");
            first.add("first_data7");
            first.add("first_data8");
            first.add("first_data9");
            first.add("first_data10");
    
            //Now copying value of first to firstname, as your requirement
            //Please refer http://www.java-examples.com/append-all-elements-other-collection-java-arraylist-example for sample code to concat two lists.
            firstname1.addAll(first);
    
            //Lets show your data into list view
    
            // Get a handle to the list view
            ListView lv = (ListView) findViewById(R.id.custom_list_view);
    
            lv.setAdapter(new ArrayAdapter<String>(CustomListView.this,
                    android.R.layout.simple_list_item_1, firstname1));
            //Please refer http://developer.android.com/reference/android/widget/ListView.html for details of setAdapter()
        }
    }
    

    Happy coding.

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

Sidebar

Related Questions

In this question I managed to combine two .png images into one, and then
I want to combine two programs into a single executable. One is an open
I want to combine these two queries into one: mysql_query(INSERT INTO categories (name, parent)
I want to combine two LambdaExpressions without compiling them. This is what it looks
I am playing with Parsec and I want to combine two parsers into one
For example, I want to combine two ranges of numbers like this: 1 2
In Clojure, I want to combine two lists to give a list of pairs,
How can I combine two lambda expressions into one using an OR ? I
Imagine two positive integers A and B. I want to combine these two into
I want to combine items of two string list but do not want repeated

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.