我有四个相同长度的数组(比如array1,array2 .... array4),我想动态地将这些数组的值传递给example array
,这样我就可以添加条件并相应地获取值。我该怎么做?
public SectionListItem[] exampleArray = { // Comment to prevent re-format
new SectionListItem("array1 data","array2 data","array3 data", "array4 data")
};
private StandardArrayAdapter arrayAdapter;
private SectionListAdapter sectionAdapter;
private SectionListView listView;
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
arrayAdapter = new StandardArrayAdapter(this, R.id.example_text_view, exampleArray);
sectionAdapter = new SectionListAdapter(getLayoutInflater(), arrayAdapter);
listView = (SectionListView) findViewById(android.R.id.list);
setListAdapter(sectionAdapter);
listView.setAdapter(sectionAdapter);
}
答案 0 :(得分:0)
这是一个简单的例子:
public class array3 {
public static void main(String[] args) {
int ar3[]={33,45,67,87,34,56};
int ar4[]={5,8,9,22,3,4};
List list1=new ArrayList();
List list2=new ArrayList();
for (int i = 0; i < ar3.length; i++) {
list1.add(ar3[i]);
}
for (int i = 0; i < ar4.length; i++) {
list2.add(ar4[i]);
}
list1.addAll(list2);
System.out.println(list);
}
}