-2

I have one recyclerview so the task is to get the data from another activity and set it to the main activity's recyclerview and when we press on particular row of list so, it get back to the editable mode and edittext fill with old data and replace it with new data and again show update data in recyclerview.

3 Answers3

0

Yes, you can do this by using the startActivityForResult() from list item adapter and at that time you can pass the data through it.

Follow the steps: 1. Implement Main Activities recyclerview 2. Get the data from another activity and show into Main Activities recyclerview. 3. Now, On List item click start the previous activity with startActivityForResult() and pass the full list or the specific list item object as per your list complexity. 4. On The Launched screen get the data from intent and show the filled data to the user. 5. As soon as user makes any change to the data and clicks on submit then finish the activity and you should handle the onActivityResult on the previous screen to update the recycler's view data.

Also, you can store the data in Shared Preferences and while launching the new screen you can get the same data from shared preferences.

0

There are three major way to communicate component of android we can say pass data, which is bellow

  • Using BroadcastReceiver: using broadcast receiver you can transfer data between tow activity or activity or service, bellow is the link which will help you
    https://developer.android.com/guide/components/broadcasts
  • Using static variable: You can declare the static variable and set value when you want to use, Like if I am declaring static variable A in Activity1 so I can change or access value of variable A from any of activity using Activity1.A.

  • Using Intent when starting activity: when we starting activity we can send data using intent put extra.

Dhaval Solanki
  • 4,589
  • 1
  • 23
  • 39
0

You can use broadcast, SharedPreferance and Static variables in android.

Mayur Patel
  • 2,300
  • 11
  • 30