Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7830911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:27:56+00:00 2026-06-02T11:27:56+00:00

I am really stuck with this problem and would appreciate some help. Firstly, I

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:27:58+00:00Added an answer on June 2, 2026 at 11:27 am

    Give that a try :

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

    In fact, simply add each entry of your set into a new HashMap

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize this question is pretty basic, but I'm really stuck. I have a
I have been stuck on this and don't really know how to go about
So the problem.. I have been stuck with this one for a good month
I have just started developing iphone applications, but now i'm stuck with this problem,
Have been stuck with this issue for a few days now, and really need,
I have a problem which bothers me for some time. I have an imageView
I'm really stuck with a problem I'm hoping someone can help me with. I'm
I have a page which contains some search fields to query a database, and
I'm really stuck trying to use java wrapper library for opencv's cvMatchTemplate. See this
I've been stuck on this for a couple of days now, and I'm really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.