我來自一個動作腳本,我對如何在java中使用數組感到困惑。如何構建數組,推送給它們,並在Java/Android中循環遍歷它們
在我的主要活動我創建了一個名爲mIcons空數組,像這樣
private Array mIcons;
現在我想通過使用從我DataBaseHelper類的方法,它看起來像這樣來設置數組的值:
public Array getHomeScreenIcons() {
Array iconList;
// Select All Query
String selectQuery = "SELECT * FROM " + homeIcons;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
iconList.push(Integer.parseInt(cursor.getString(0)));
} while (cursor.moveToNext());
}
Log.v(TAG, "List Created");
// return contact list
}
大膽線跳出的代碼是問題至今..我怎麼推到我的數組
再後來我將要運行一個for循環從數組我主要活動using.length
瞭解原始語言結構的最好方法是通過一本書或在線教程。這個問題涉及這樣的基本語法,它不屬於SO。 – 2012-03-07 20:43:33