Home > Software engineering >  How can I add a button on one main activity that links to another main activity in android studio?
How can I add a button on one main activity that links to another main activity in android studio?

Time:11-10

I don’t really program that much but I am developing a simple application just for fun and some experience. I am trying to have two buttons on one page of my app that links to two charts/ graphics displays of data on another page. I have developed each part as a separate main activity but I’m struggling to put them all together. I’ve looked at guides online but android studio has been updated to the point to which some of those methods don’t work(I keep running into this problem) can anyone give me some pointers to the current method of getting this done?

I have tried the methods of various videos but none of them worked.

CodePudding user response:

i think you want to go from first activity to another activity using button

important point is

  1. be sure with activity link exist in manifest.xml

    activity android:name=".ToActivity" android:label="@string/app_name"

  2. then add intent

    Intent intent = new Intent(FromActivity.this, ToActivity.class);

    startActivity(intent);

  • Related