Change recylcerview item's ui on button click from another activity in kotlin


So I have a recylcerview as shown below. When I clcik on the "Invite to job" button it opens up another activity which has a button. And on that button clcik I want to disable the selected item's button and change its text to "Invited". :

enter image description here

This is what I tried. I passed a boolean using the shared preferences when the button from another activity is clciked.

 sharedPref.putBoolean(Constants.CHANGE_INVITE_BUTTON, true)

And then in the recyclerview's adapter I added this inside onBindViewHolder :

                holder.binding.inviteToJobButtonFreelancerScreenCu.isEnabled = false
                holder.binding.inviteToJobButtonFreelancerScreenCu.text = "Invited"

                holder.binding.inviteToJobButtonFreelancerScreenCu.setOnClickListener {


If the value is true then just change the text and disable the button but if it's not then continue to open the activity with that button. But now when I run it all the buttons are disabled and their texts have it is not working properly at all.

Please help me out here. Thanks

answered question

1 Answer


When you click on Invite Job Button you need to take one boolean variable that indicates you invite for that particular job or not in your model which you bind in your RecyclerView. And by default that boolean id false for all Jobs.

Once you click on Invite Job Button then you need to do that Boolean as true and notify your Adapter.

Text change and disable button you need to do based on your Boolean.

posted this

Have an answer?


Please login first before posting an answer.