Skip to content Skip to sidebar Skip to footer

Enable A Button Android From A Different Activity

In my code I have a disabled button in the activity 'A' Can I enable that button on the activity 'A' from an activity 'B'? Thanks.

Solution 1:

Normally, you cannot.

If you are invoking activity A from activity B, then you can pass information on whether to enable the button via the intent.

If A invoked B and you need to do something back in A based on user's actions in B, then you can invoke B with startActivityForResult and send the result back from B to A; then in onActivityResult of your activity A you can enable/disable the button based on what B has passed back.

Solution 2:

Use one Global class and declare static boolean flag variable

and set flag value as you want and set Button's property btn.setEnabled(Global.flag);

Post a Comment for "Enable A Button Android From A Different Activity"