2012-04-20 3 views
0

私は本当にこの問題に固執していて、助けていただければ幸いです。CustomAdapterで表示するためにSETをHASHMAPに戻す方法

まず、私は、単純なハッシュマップが含まれているサービスを実行している

ORIG_MSG_MAPは整数、文字列のキーと値のペアを持つハッシュマップです。サービスは私の活動の

//get entries in the hash 
public Set<Entry<String, Integer>> getNumbers() { 
    // TODO Auto-generated method stub 

    return ORIG_MSG_MAP.entrySet(); 


} 

セットとしてハッシュマップの内容を返すメソッドを持っている私は、サービスと対話していますし、私はハッシュマップではないSETで作業する必要がcustomAdapterの私のコンストラクタを呼び出す

活動

 /** 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。行、???));

MyCustomAdapterためConstuctor彼は

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()); 

}

ハッシュは、あなたは私が戻ってハッシュに設定

おかげで、

グラハム

答えて

1

を変換する助けてください期待してい試してみてください:

Set<Entry<String, Integer>> yourSet; 
HashMap<String,Integer> yourMap = new HashMap<String,Integer>(); 
for (Entry<String,Integer> entry : yourSet) { 
    yourMap.put(entry.getKey(),entry.getValue()); 
} 

は実際には、単に新しいHashMapのに

+0

FANTASTIC、感謝万人をあなたのセットの各エントリを追加します – user803271

関連する問題