我需要你的帮助!谷歌上的 3 页紫色链接,我被这么简单的任务困住了!我想要做的是获取一个包含多个 HashMap 的 HashMap 类型的 ArrayList,并使用 ListAdapter 显示它们。我从 SQL DB 获取信息,我知道这是可能的,但我看不出我做错了什么,列表只是显示为空白。
public class History extends ListActivity {
ArrayList<HashMap<String, String>> inboxList;
HashMap<String, String> dealList;
ListView lv;
AddSQL entry;
Button bRefresh;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.history);
entry = new AddSQL(History.this);
inboxList = new ArrayList<HashMap<String, String>>();
ListAdapter adapter = new SimpleAdapter(History.this, inboxList, R.layout.history_list, new String[] { SEX, NAME, RATING, DATE },
new int[] { R.id.sex, R.id.name, R.id.rating, R.id.date });
inboxList = entry.getAllEntrys();
setListAdapter(adapter);
}
/** 这是我的 SQL */
public ArrayList<HashMap<String, String>> getAllEntrys(){
Log.d("Select", "Get");
String s = "";
String n = "";
String r = "";
String d = "";
String select = "SELECT sex, name, rating, date FROM " + MAIN_TABLE;
ArrayList<HashMap<String, String>> inboxList = new ArrayList<HashMap<String, String>>();
Log.d("Select", "1");
try{
open();
Cursor mCursor = database.rawQuery(select, null);
while(mCursor.moveToNext()){
HashMap<String, String> dealList = new HashMap<String, String>();
s = mCursor.getString(mCursor.getColumnIndex(SEX));
n = mCursor.getString(mCursor.getColumnIndex(NAME));
r = mCursor.getString(mCursor.getColumnIndex(RATING));
d = mCursor.getString(mCursor.getColumnIndex(DATE));
dealList.put(SEX, s);
dealList.put(NAME, n);
dealList.put(RATING, r);
dealList.put(DATE, d);
inboxList.add(dealList);
}
return null;
}catch (Exception e){
Log.e("Sort By List", "ERROR: " + e);
e.printStackTrace();
}
return null;
}