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

Issue

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.

Solution

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);

Answered By – MAYUR SANCHETI

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published