0% found this document useful (0 votes)
79 views2 pages

Activity1.java: Package Import Import Import Import Import Public Class Extends

The document contains code for an Android application with two activities. Activity1 has a button that, when clicked, starts a new intent to launch Activity2. The layout files for each activity define the user interface with text labels and a button.

Uploaded by

Vanita Bains
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views2 pages

Activity1.java: Package Import Import Import Import Import Public Class Extends

The document contains code for an Android application with two activities. Activity1 has a button that, when clicked, starts a new intent to launch Activity2. The layout files for each activity define the user interface with text labels and a button.

Uploaded by

Vanita Bains
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Activity1.

java
package com.example.animation;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.content.Intent;

public class activity1 extends AppCompatActivity {


Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity1);
btn=(Button)findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i= new Intent(activity1.this,activity2.class);
startActivity(i);
}
});

}
}
activity1.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity1"
android:background="@drawable/background">

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="114dp"
android:layout_marginLeft="114dp"
android:layout_marginTop="216dp"
android:text="ACTIVITY1"
android:textSize="30sp" />

<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="147dp"
android:layout_marginLeft="147dp"
android:layout_marginTop="297dp"
android:text="Click Me" />
</RelativeLayout>
Activity2.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity1"
android:background="@drawable/bg1">

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="108dp"
android:layout_marginLeft="108dp"
android:layout_marginTop="250dp"
android:text="ACTIVITY2"
android:textSize="30sp" />

</RelativeLayout>

You might also like