Tell me please, I want to make it possible to edit item 'a in the RecyclerView list.

As I understand it, you need to change the item and notify the adapter about it. To change the item 'and I plan to transfer data to another Activity , and upon completion of editing, return to the adapter.

In order for me to use the startActivityForResult method, I have to inherit from the AppCompatActivity in the adapter, which is not possible, since I'm inheriting from RecyclerView.Adapter<RecyclerViewAdapterPart.ViewHolder> .

Where to dig?

    1 answer 1

    In order for me to use the startActivityForResult method, I must inherit the adapter from AppCompatActivity in the adapter

    Inheriting the adapter class from the activity class is a very strange idea. An adapter is an adapter, a activity is an activity . These are completely different classes.

    You can call the startActivityForResult method, for example, passing to the adapter Context :

     MyAdapter(Context context) { mContext = context; } 

    And then use it to call the desired method:

     ((Activity) mContext).startActivityForResult(intent, REQUEST_FOR_ACTIVITY_CODE); 
    • Thanks for the answer, it works. And why not to inherit from AppCompatActivity? - Alexander
    • @Alexander, Because your class is an adapter, not an activity . - post_zeew