How to pass Custom List Object using intent, I am working on android application and in that I want to pass a Cutom list Object to other activity via intent. I have made that CustomList class I am trying to pass an arrayList to another activity using intents. Here is the code in the first activity. case R.id.editButton: Toast.makeText(this, "edit was clicked", Toast.LENGTH_LONG
Android, android documentation: Passing custom object between activities. //Getting MyObject List Intent mIntent = getIntent(); ArrayList<MyObjects> mUsers = mIntent. In the blog, we have shown you how to pass the List of CustomObjects to the Activity and fragment. In this technique, we have used the Serialization for the list passing. Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file.
pass list to intent in android java Code Example, “pass list to intent in android java” Code Answer. Intent intent = new Intent(getApplicationContext(),YourActivity. class); Bundle bundle = new Bundle(); bundle. putParcelable("data", sharedBookingObject); intent. putExtras(bundle); startActivity(intent); private List<String> test; Init List at appropriate place. test = new ArrayList<String> (); and add data as appropriate to test. Pass to intent as follows: Intent intent = getIntent(); intent.putStringArrayListExtra("test", (ArrayList<String>) test); Retrieve data as follows:
No comments:
Post a Comment