0

I'm developing an android app in which I want to apply button visibility functionality in activity_2 and that visibility should depend on button click from activity_1

Ex. In activity_2 I have :

<Button android:id="@+id/button1"
android:text="ABC"
android:visibility="gone"/>

It should visible on button click from activity_1

Activity_1 :

<Button android:id="@+id/button1"
android:text="ABC"/>       

Please suggest me, I'm a beginner

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Vasim
  • 9
  • 2

2 Answers2

0

Pass the visibility you want from Activity A to Activity B in a Bundle.

Passing a Bundle on startActivity()?

Kuffs
  • 35,581
  • 10
  • 79
  • 92
  • Yes..I Think so we can use Bundle but I don't know how to use.Please explain in detail. – Vasim Nov 02 '17 at 07:53
0

Try this:

On clicking the button in the first activity,send a value to second activity through intent.

 Intent intent = new Intent(Activity1.this,Activity2.class);
 intent.putExtra("button","clicked");
 startActivity(intent);

And then get this value in the onCreate of second activity like this:

 String value = getIntent().getStringExtra("button");

then check the value with if statement

 if(value.equalsIgnoreCase("clicked")){
    //make your button visible here
  }
 else{
   //button not visible
  }