Android studio open new activity on button click in android by existing activity

Android studio Tutorials 3



What is an "activity" in Android Studio?


An activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows.


On every android application there Intent used to open new activity Without intent function developer cannot open another activity. Intent function is used like Anchor tags or you can say that Intent is anchor tag of android applications. So here is the complete step by step tutorial for Open new activity on button click in android by existing activity.

Opening another activity through Intent function.


step 1  creat new activity

Right click app folder

New

Activity

Empty Activitty


See the screen shot

Step 2

Creates a new empty activity

Activity name > Another Activity

Done

See  screen shots


Step 3 


Open main activity xml

Add the code in main activity xml text

<Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:onClick="Another Activity"               
       android:text="Start Another Activity"/>

Step 4 

Open  main Activity.java

add the codes



} 
        public void Another Activity(View view) {
        Intent intent=new Intent(MainActivity.this,AnotherActivity.class);
        startActivity(intent);








Comments

  1. Android Studio Open New Activity On Button Click In Android By Existing Activity - Mallu Tips >>>>> Download Now

    >>>>> Download Full

    Android Studio Open New Activity On Button Click In Android By Existing Activity - Mallu Tips >>>>> Download LINK

    >>>>> Download Now

    Android Studio Open New Activity On Button Click In Android By Existing Activity - Mallu Tips >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete

Post a Comment