Vasant
Vasant

Reputation: 3585

how to store android UI component in Parcelable class?

I am working on Parcelable class for storing data into arraylist and pass from one activity to other activity.but parcelable model class contain android component textview so, how can I read that component in parcelable class?

enter image description here

Your answer would be appreciated.

Upvotes: 2

Views: 531

Answers (3)

Roman Samoilenko
Roman Samoilenko

Reputation: 936

You cannot put into Plain Old Java Object Android-specific views such as TextView.
Read the documentation:
https://developer.android.com/reference/android/os/Parcel.html

Upvotes: 3

EpicPandaForce
EpicPandaForce

Reputation: 81568

The TextView is not Parcelable, therefore it cannot be parcelled.

It has a reference to a Context anyways, so the notion of putting it into a data object and sending it to one place from another is somewhat ridiculous. You get pretty much the same thing by sending textView.getText().

Upvotes: 3

CommonsWare
CommonsWare

Reputation: 1007276

You don't. You cannot pass a View between processes, which is a requirement of Parcelable.

Have CustBean hold a String, which contains the text that had been in the TextView in the first activity, so the second activity can create its own TextView to show that String to the user.

Upvotes: 4

Related Questions