Wednesday 15 September 2010

java - Serializable object to Arraylist of Hashmap -


I am developing an Android application, where I display all the names of contacts in a list view.

Click on the contact list view, I need to display the related numbers of that contact in another list view.

The problem here is that I collected all the numbers and sent it another activity and received the bundle, but the received bundle is a serialjable object.

So, to clarify in the list, it is necessary to change it to the Hesmap array list. How can I do this?

Here is the code:

Sending activity:

  hashmap < String, string & gt; Numbermap = new hashmap & lt; String, string & gt; (); Numbermap.put ("numbered", number); Numbermap.put (type "type"); NumberList.add (Numbermap); Intent = Intentional Intent (ContactNames.this, Contact PhoneNumbers.class); Intent.putExtra ("map", number list); StartActivity;   

Receiving activity:

  serialjob numbermap = new hashmap & lt; String, string & gt; (); //contum = (TextView) Find VVBIID (RID ContactCamber); Bundle bundle = getIntent (). GetExtras (); Intent = getIntent (); If (bundle! = Null) {Numbermap = bundle.getSerializable ("map"); }   

You put the "map" in the intent with the object, the object Number list which is an example of ArrayList , I think. But in your activity, the contactphone bonus , you try to get an example of Hasham with the key "map", which is not correct.

All you have to do is:

  Arreelist & lt; Hashmap & lt; String, string & gt; & Gt; NumberList = null; Bundle bundle = getIntent (). GetExtras (); Intent = getIntent (); If (bundle! = Null) {numberList = (arreelist & lt; hashmap; string; string & gt; & gt;) bundle.getSerializable ("map"); }    

No comments:

Post a Comment