0
我正在使用SQlite Database.I創建2個表並填充它們(正常工作),並使用那裏的數據以列表視圖顯示。當第一次列表適配器正在填充列表視圖時顯示newDATA varibale爲零。一些數據。但是當我回去並進一步開始該活動時,newDATA具有正確的值。 。我用下面的代碼當第一次活動開始時,列表視圖不會填充數據庫
public ArrayList<HashMap<String, Object>> GetDataFirst(String id) {
ArrayList<HashMap<String, Object>> firstvariable = new ArrayList<HashMap<String, Object>>();
Cursor c =sdb.rawQuery("Select * from table_name ",new String[]{id});
String[] colums = c.getColumnNames();
while (c.moveToNext()) {
HashMap<String, Object> record = new HashMap<String, Object>();
for (int i = 0; i < colums.length; i++) {
record.put(colums[i], c.getString(c.getColumnIndex(colums[i])));
}
{
ArrayList<HashMap<String, String>> now_add = GetmainData(id, record.get("vget").toString());
record.put("NewDATA", now_add);
hint.add(record);
}
}
}
c.close();
return firstvariable ;
}
public ArrayList<HashMap<String, String>> GetCluesDataVerical(String id,String vhid) {
ArrayList<HashMap<String, String>> hint = new ArrayList<HashMap<String, String>>();
Cursor c = sdb.rawQuery("SELECT * FROM table_data", new String[] {id,vhid});
String[] colums = c.getColumnNames();
while (c.moveToNext()) {
HashMap<String, String> record_add = new HashMap<String, String>();
for (int i = 0; i < colums.length; i++) {
record_add.put(colums[i], c.getString(c.getColumnIndex(colums[i])));
}
hint.add(record_add);
}
c.close();
return hint;
}
,並在列表適配器我這些如下呼籲:
recordData=context.crossDatabaseAdapter.GetDataFirst(value);
wArray = (ArrayList<HashMap<String, String>>) recordData.get(position).get("NewDATA");
我嘗試了很多,但仍然沒有提出任何解決方案。