EDIT
Since Sevin noticed that I am not giving you a solution, but an alternative way to achieve your goal, I have been editing this.
First: your code should work
Correctly executed code
Now do a few checks:
- Make sure the button is not zero in debug mode (an exception must be thrown)
- Make sure in debug mode you reach onClick, even if the text does not change and even if the toast does not appear.
- Check if you are showing the fragment correctly. Here is the official documentation on how to create a snippet.
- Check if the fragment is available, and if it has something (just the pressed button shows the classic "click" animation?)
- Check the xaml code if the correct button is assigned to the identifier you specified.
And finally, perform the following operations:
- Clean up project
- Rebuild your project
- Check if you have any signal in the xaml and java code (in the basic configurations, a yellow sign above the line)
- Uninstall the application and reinstall it (almost the same, but since we donβt know your project, it can still help)
After that, let us know
Possible Solution:
You have a recycleview that sits on top of the button . you have this view with match parent both height and width inside relativelayout , this means that this view will span the button.
Remove this empty recycleview and the code will work
source share