-1

I'm creating own List with 4 parameters. I have an example with standard list with 2 parameters.
How can I declare ArrayList for 4 parameters and not 2?

ArrayList<Map<String, String>> list = buildData();
String[] from = { "name", "purpose" };
int[] to = { android.R.id.text1, android.R.id.text2 };
Julien Poulin
  • 12,737
  • 10
  • 51
  • 76
user1582087
  • 93
  • 1
  • 3
  • 10
  • http://stackoverflow.com/questions/4956844/hashmap-with-multiple-values-under-the-same-key what you want is a hashmap with four values not a arraylist with 4 parameters! – Ashwani Oct 11 '12 at 09:31

2 Answers2

2

Create a class that contains four parameters. for example:

public class MyClass {

    public String param1;

    public String param2;

    public String param3;

    public String param4;
}

Then, declare your arraylist as:

ArrayList< MyClass > list = buildData();

String[] from = { "name", "purpose", .... };

    int[] to = { android.R.id.text1, android.R.id.text2, ... };

Hope that helps. :)

Rolf ツ
  • 8,611
  • 6
  • 47
  • 72
kdroider
  • 731
  • 5
  • 20
0

An implementation of Map will be appropriate here.

public class SomeClass{

    public String str1;

    public String str2;

    public String str3;

    public String str4;


}


ArrayList<SomeClass, HashMap<String, String>> map = newArrayList<SomeClass,HashMap<String, String>>();
Kumar Vivek Mitra
  • 33,294
  • 6
  • 48
  • 75