我試圖創建數組的列表,動態大小,添加元素並在完成時遍歷它們。目前我的代碼是:創建並遍歷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