How to Create a New Activity | Open New Activity in Android Studio Episode #008

Create a New Activity Open New Activity

How to Create a New Activity | Open New Activity in Android Studio

XML Code

<Button
android:id=”@+id/next”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:background=”#4CAF50″
android:layout_gravity=”center”
android:text=”Next Activity”
android:textSize=”30dp”
/>

 

Java Code

Button next;

next = (Button)findViewById(R.id.next);

 next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, aboutus.class);
            startActivity(intent);
        }
    });
}