将通用ArrayList转换为Array

时间:2014-07-30 10:03:38

标签: arrays generics arraylist

我试图将DataBaseHandler返回的List转换为Array.I出错

final DatabaseHandler db = new DatabaseHandler(MainCourseList.this);
List<coursedb>  contacts = db.getAllContacts(); //getting all records from database as a List
Collections.sort(elements);
images=pics.toArray(new String[pics.size()]);
String[] itemArray = new String[contacts.size()]; //converting the LIst to array
titles= contacts.toArray(itemArray);

descriptions = elements.toArray(new String[elements.size()]);

rowItemps = new ArrayList<CourseItem>();
for (int i = 0; i < descriptions.length; i++)
{
    CourseItem item = new CourseItem(descriptions[i],images[i],titles[i]);// using the array values to add to listView
    rowItemps.add(item);
}

listView = (ListView) findViewById(R.id.clist);
adapter = new CourseAdapter(this, rowItemps);
listView.setAdapter(adapter);

0 个答案:

没有答案