I am really stuck with this problem and would appreciate some help.
Firstly, I have a service running which contains a simple hashmap
ORIG_MSG_MAP is a hashmap with Integer,String key value pairs. The service has a method to return the contents of the hashmap as a set
//get entries in the hash
public Set<Entry<String, Integer>> getNumbers() {
// TODO Auto-generated method stub
return ORIG_MSG_MAP.entrySet();
}
in my activity I am interacting with the service and then I call my constructor in customAdapter which needs to work with a hashmap not a SET
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();
—-> The question marks should be a reference to a hash with key,value pairs <—-
setListAdapter(new MyCustomAdapter(DynamicLists.this, R.layout.row, ???));
Constuctor for MyCustomAdapter he expects a hash
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());
}
Can you please help me convert a set back to a hash
Thanks,
Graham
Give that a try :
In fact, simply add each entry of your set into a new HashMap