我试图创建数组的列表,动态大小,添加元素并在完成时遍历它们。目前我的代码是:创建并遍历Java中的字符串列表
String activities = "SELECT DISTINCT phoneactivity from ContextTable030313";
ArrayList<String> myActivities = new ArrayList();
Cursor cursor2 = db.rawQuery(activities, null);
// looping through all rows and adding to list
if (cursor2.moveToFirst()) {
do {
myActivities.add(cursor.getString(cursor2.getColumnIndex("ts")));
} while (cursor2.moveToNext());
}
但它无法在do循环中运行。我相信我错误地宣布什么,我得到以下警告:
- ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized
- Avoid object allocations during draw/layout operations (preallocate and reuse instead)
- Type safety: The expression of type ArrayList needs unchecked conversion to conform to
ArrayList<String>
但我不明白为什么这是行不通的。
前的Java 7,应该来在两侧。即新ArrayList ()以及 –
rajesh
2013-03-05 06:38:15
我做到了这一点,我仍然得到以下警告:“在绘制/布局操作期间避免对象分配(预分配和重用,而不是)”和我的代码仍然在做循环失败.... – WildBill 2013-03-05 06:41:23
检查这个http://stackoverflow.com/questions/11490611/android-roundrectshape-modify-corner-radii – rajesh 2013-03-05 06:42:46