For example, I have created one activity in recycler view and gave the contains i.e., name, title and heading and also I have put OnClick Listener in the adapter class. Now I want to implement that when I click on first item then it should open another activity and it should display different data like when Clicked in particular person's then it should display the details his/her ssn etc. I have created all these but it shows same data in 1st activity and same data in 2nd activity.
1st activity:
- name: xyz
- title: founder
- heading: awesome
after click on that TextView then it should display as: 2nd activity:
- name: xyz
- title: founder
- heading: awesome
- description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis aliquet, lectus sed laoreet lobortis, erat arcu sodales purus, ut pharetra quam erat ac quam. Ut dui augue, suscipit vel dui eget, ultricies efficitur ante. Mauris sollicitudin mattis nibh sed feugiat.
You can start activity from your adapter with parameter.
If you need to pass object, you should implement your data class to Serializable or Parcelable.
Data Class
You can retrieve data that you passed from first activity.
Adapter Class
Adapter Implementation is as follow. In this sample codes, I implement ListAdater rather than RecyclerAdapter.
DataVH Class hold Data as a state and put it as extra data with Intent Object.
Second Activity
This is the codes within Second Activity, that has been launched from DataVH.
Happy Coding
Regards!