0% found this document useful (0 votes)
33 views5 pages

Android Project Sample

The document describes an Android app with a main activity layout containing buttons to navigate to activity classes for different animals (cat, lion, rat, zebra). The main activity class handles button clicks to start the corresponding animal activities using intents. Sample cat activity and manifest files are also included.

Uploaded by

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

Android Project Sample

The document describes an Android app with a main activity layout containing buttons to navigate to activity classes for different animals (cat, lion, rat, zebra). The main activity class handles button clicks to start the corresponding animal activities using intents. Sample cat activity and manifest files are also included.

Uploaded by

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

Resource _layout

1 main Activity

<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Animal History"
android:gravity="center"
android:textSize="25dp"
android:layout_marginTop="25dp"/>
<Button
android:id="@+id/bcat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="cat"
android:textColor="#00ffff"
android:textSize="25dp"
android:layout_marginTop="25dp"/>

<Button
android:id="@+id/brat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Rat"
android:textColor="#00ffff"
android:textSize="25dp"
android:textStyle="italic"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="106dp" />

<Button
android:id="@+id/blion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="lion"
android:textColor="#00ffff"
android:textSize="25dp"
android:textStyle="italic"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />

<Button
android:id="@+id/bzebra"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="zebra"
android:textColor="#00ffff"
android:textSize="25dp"
android:textStyle="italic"
tools:layout_editor_absoluteX="50dp"
tools:layout_editor_absoluteY="159dp"
tools:ignore="MissingConstraints" />
</LinearLayout>

2. History

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


<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView"
android:layout_width="363dp"
android:layout_height="397dp"
android:text="history of cat is as follow
ghjkhklfjsdklfjskldjfklsdjkljkljsdfpi;l;kljsdfk
lnjkhjnsdfkjhajkhsadfhjkhjkndkjfuihjkfgklsdfdg"
android:textSize="30dp"
tools:layout_editor_absoluteX="34dp"
tools:layout_editor_absoluteY="43dp"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>

Java

1. Main_activity
package com.example.lalisee;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View btnc=findViewById(R.id.bcat);
btnc.setOnClickListener(this);
View btnb=findViewById(R.id.brat);
btnb.setOnClickListener(this);
View btni=findViewById(R.id.blion);
btni.setOnClickListener(this);
View btnz=findViewById(R.id.bzebra);
btnz.setOnClickListener(this);
}

@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.bcat:
Intent intent= new Intent(this,cat.class);
startActivity(intent);
break;
case R.id.brat:
Intent inten= new Intent(this,rat.class);
startActivity(inten);
break;
case R.id.blion:
Intent intentt= new Intent(this,lion.class);
startActivity(intentt);
break;
case R.id.bzebra:
Intent intenty= new Intent(this,zebra.class);
startActivity(intenty);
break;
}
}
}
2. java class for cat

package com.example.lalisee;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class cat extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cat_history);
}}

3. manifests

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


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Lalisee"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
<activity android:name=".cat"/>
<activity android:name=".lion"/>
<activity android:name=".rat"/>
<activity android:name=".zebra"/>
</application>

</manifest>

You might also like