0
我真的被這個問題困住了,希望得到一些幫助。如何將SET轉換回HASHMAP以在customAdapter中顯示
首先,我有一個服務運行包含一個簡單的HashMap
ORIG_MSG_MAP是整數,字符串鍵值對的HashMap中。該服務必須返回HashMap中的內容爲一組
//get entries in the hash
public Set<Entry<String, Integer>> getNumbers() {
// TODO Auto-generated method stub
return ORIG_MSG_MAP.entrySet();
}
在我的活動,我的服務進行交互,然後我打電話給我在customAdapter構造函數,需要與一個HashMap不是一套工作方法
ACTIVITY
/** Defines callbacks for service binding, passed to bindService() */
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
// We've bound to LocalService, cast the IBinder and get LocalService instance
LocalBinder binder = (LocalBinder) service;
mService = binder.getService();
mBound = true;
Set<Entry<String, Integer>> whatsup = mService.getNumbers();
---->問號應該是一個參照本發明的散列與鍵,值對< ---- setListAdapter(新MyCustomAdapter(DynamicLists.this,R.layout。行,)));
Constuctor爲MyCustomAdapter他預計哈希
public MyCustomAdapter(DynamicLists dynamicLists, int row, HashMap<String, Integer> map){
mData = map;
mKeys = mData.keySet().toArray(new String[map.size()]);
Log.d(TAG, "INSIDE ADAPTER constructor HELLO WORLD " + map.entrySet());
}
能否請你幫我轉換設置回哈希
感謝,
格雷厄姆
太棒了,太感謝了。 – user803271 2012-04-20 12:49:35