0% found this document useful (0 votes)
21 views20 pages

Mad 18

Uploaded by

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

Mad 18

Uploaded by

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

1)

Acitivty_main.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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="#CF85D9">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textStyle="bold"
android:textSize="20dp"
android:layout_marginTop="200dp"
android:layout_marginLeft="30dp"
android:id="@+id/text"
/>

<EditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:hint="Enter your username"

android:layout_marginTop="190dp"

android:layout_marginLeft="150dp"

android:textStyle="bold"

android:id="@+id/edit"/>
<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Password"

android:textSize="20dp"

android:textStyle="bold"

android:layout_marginTop="250dp"

android:layout_marginLeft="30dp"

android:id="@+id/view"/>

<EditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:hint="Enter your password"

android:textStyle="bold"

android:layout_marginTop="240dp"

android:layout_marginLeft="150dp"

android:id="@+id/text1"/>

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="login"

android:textStyle="bold"

android:layout_marginTop="320dp"

android:layout_marginLeft="150dp"

android:id="@+id/but"/>

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Result"

android:textSize="30dp"

android:textStyle="bold"
android:layout_marginTop="400dp"

android:layout_marginLeft="150dp"

android:id="@+id/text2"/>

</RelativeLayout>

MainActivity.java
package com.example.lochan;

import com.example.lochan.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends Activity {


TextView text;
TextView view;
TextView text2;
EditText edit;
EditText text1;
Button but;

@Override
protected void onCreate(Bundle abc) {
super.onCreate(abc);
setContentView(R.layout.activity_main);
text = findViewById(R.id.text);
text1 = findViewById(R.id.text1);
text2 = findViewById(R.id.text2);
but = findViewById(R.id.but);

view = findViewById(R.id.view);

edit = findViewById(R.id.edit);

but.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

String Username = edit.getText().toString();

String Password = text1.getText().toString();

if(Username.equals("Lochan") && Password.equals("2005"))

Intent obj = new Intent(MainActivity.this, MainActivity2.class);

startActivity(obj);

else{

text2.setText("Login Unsuccessfull!!!");

});

}
}
Acitivty_main2.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:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity2"
android:background="@color/white">

<TextView

android:layout_width="match_parent"

android:layout_height="match_parent"

android:text="WELCOME HERE !!!"

android:textSize="50dp"

android:textStyle="bold"

android:textColor="@color/black"

android:layout_marginTop="150dp"/>

</RelativeLayout>

MainActivity2.java
package com.example.lochan;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

public class MainActivity2 extends AppCompatActivity{

@Override

protected void onCreate(Bundle abc){

super.onCreate(abc);

setContentView(R.layout.activity_main2);

}
2)

Acitivty_main.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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="#CF85D9">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textStyle="bold"
android:textSize="20dp"
android:layout_marginTop="200dp"
android:layout_marginLeft="30dp"
android:id="@+id/text"
/>

<EditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:hint="Enter your username"

android:layout_marginTop="190dp"

android:layout_marginLeft="150dp"

android:textStyle="bold"

android:id="@+id/edit"/>
<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Password"

android:textSize="20dp"

android:textStyle="bold"

android:layout_marginTop="250dp"

android:layout_marginLeft="30dp"

android:id="@+id/view"/>

<EditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:hint="Enter your password"

android:textStyle="bold"

android:layout_marginTop="240dp"

android:layout_marginLeft="150dp"

android:id="@+id/text1"/>

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="login"

android:textStyle="bold"

android:layout_marginTop="320dp"

android:layout_marginLeft="150dp"

android:id="@+id/but"/>

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Result"

android:textSize="30dp"

android:textStyle="bold"
android:layout_marginTop="400dp"

android:layout_marginLeft="150dp"

android:id="@+id/text2"/>

</RelativeLayout>

MainActivity.java
package com.example.lochan;

import com.example.lochan.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends Activity {


TextView text;
TextView view;
TextView text2;
EditText edit;
EditText text1;
Button but;

@Override
protected void onCreate(Bundle abc) {
super.onCreate(abc);
setContentView(R.layout.activity_main);
text = findViewById(R.id.text);
text1 = findViewById(R.id.text1);
text2 = findViewById(R.id.text2);
but = findViewById(R.id.but);

view = findViewById(R.id.view);

edit = findViewById(R.id.edit);

but.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

String Username = edit.getText().toString();

String Password = text1.getText().toString();

if(Username.equals("Lochan") && Password.equals("2005"))

Intent obj = new Intent(Intent.ACTION_MAIN);

obj.setPackage("com.google.android.youtube");

startActivity(obj);

else{

text2.setText("Login Unsuccessfull!!!");

});

}
}
Acitivty_main2.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:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"
tools:context=".MainActivity2"

android:background="@color/white">

<TextView

android:layout_width="match_parent"

android:layout_height="match_parent"

android:text="WELCOME HERE !!!"

android:textSize="50dp"

android:textStyle="bold"

android:textColor="@color/black"

android:layout_marginTop="150dp"/>

</RelativeLayout>

MainActivity2.java
package com.example.lochan;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

public class MainActivity2 extends AppCompatActivity{

@Override

protected void onCreate(Bundle abc){

super.onCreate(abc);

setContentView(R.layout.activity_main2);

}
3) Acitivty_main.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:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity"

android:background="@color/white">

<TextView

android:layout_width="match_parent"

android:layout_height="match_parent"

android:text="Ganapati Bappa Morya!!"

android:textSize="50dp"

android:textStyle="bold"

android:textColor="#CA4D42"

android:layout_marginTop="150dp"/>

</RelativeLayout>

MainActivity.java
package com.example.lochan;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.os.Handler;

public class MainActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) { // changed abc to savedInstanceState

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

new Handler().postDelayed(() -> {

Intent obj = new Intent(MainActivity.this, MainActivity2.class);

startActivity(obj);

finish();

}, 3000); // added comma after lambda expression

Acitivty_main2.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:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity2"

android:background="@color/white">

<ImageView

android:layout_width="match_parent"

android:layout_height="match_parent"

android:src="@drawable/img2"/>

</RelativeLayout>

MainActivity2.java
package com.example.lochan;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;
public class MainActivity2 extends AppCompatActivity{

@Override

protected void onCreate(Bundle abc){

super.onCreate(abc);

setContentView(R.layout.activity_main2);

}
4) Activity2_main.xml –
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity2"
android:background="#EAD7F4"
android:orientation="vertical"
android:padding="60dp">

<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
/>

<EditText
android:id="@+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="enter username"/>

<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password"
/>

<EditText
android:id="@+id/edt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="enter password"/>

<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"/>

<TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>

MainActivity2.java –
package com.example.relativelayout;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity2 extends AppCompatActivity {

EditText editText1;
TextView textView3;
EditText editText2;
Button button;

@Override
protected void onCreate(Bundle abc) {
super.onCreate(abc);
setContentView(R.layout.activity_main2);
editText1=findViewById(R.id.edt1);
editText2=findViewById(R.id.edt2);
button=findViewById(R.id.btn);
textView3=findViewById(R.id.tv3);

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String username=editText1.getText().toString();
String password=editText2.getText().toString();
if(username.equals("abc") && password.equals("123"))
{
Intent obj=new Intent(MainActivity2.this,MainActivity3.class);
startActivity(obj);
}
else{
textView3.setText("Login Unsuccessfull!");
}
}
});

}
}

Actvity_main3.xml –
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity3">

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity3.java –
package com.example.relativelayout;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity3 extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main3);

}
}

You might also like