Ad

Change Text Content Depending On Button Clicked Within The Same Class

My problem is exactly like this link but it's not in android.

I have one button on a layout and two buttons on an another one. On my application, ClickScreen activity can be triggered by either FirstCase activity or SecondCase activity.

I tried to make a conditional statement on my ClickScreen for which activity is triggered but couldn't handle it. I don't want to create two more classes to do this since it's not an efficient technique.

private void goTo2ndPage() {
    Intent i3 = new Intent(this, ClickScreen.class);
    startActivity(i3);
}

public class ClickScreen extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.click_screen);

    }
}
Ad

Answer

As we discussed in comments. It looks like what you really want is to add extra data in your intent so that Started Activity can get it and act accordingly.

Check out this post !

Ad
source: stackoverflow.com
Ad