Category Archives: Arrays

How to pass an arraylist value from one activity to another in android?

By | October 28, 2012

This simple example shows how to pass an ArrayList from one activity to another in Android. This is the first activity on which we are sending the arrayList. MainActivity [java] package com.coderzheaven.passarraylist; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) {… Read More »

All about ArrayList – Android.

By | October 12, 2012

[java] package com.coderzheaven.arraylistcomplete; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Vector; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @SuppressWarnings("unchecked") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ArrayList<String> al = new ArrayList<String>(); System.out.println("Initial size of al: " + al.size()); al.add("C"); al.add("A"); al.add("E"); al.add("B"); al.add("D"); al.add("F"); al.add(1, "A2"); System.out.println("Size of al after… Read More »