0% found this document useful (0 votes)
59 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)
59 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

Resource _layout

1 main Activity

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


<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
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"?>


<[Link] xmlns:android="[Link]
xmlns:tools="[Link]
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" />
</[Link]>

Java

1. Main_activity
package [Link];

import [Link];

import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity implements [Link]{

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
View btnc=findViewById([Link]);
[Link](this);
View btnb=findViewById([Link]);
[Link](this);
View btni=findViewById([Link]);
[Link](this);
View btnz=findViewById([Link]);
[Link](this);
}

@Override
public void onClick(View view) {
switch ([Link]()){
case [Link]:
Intent intent= new Intent(this,[Link]);
startActivity(intent);
break;
case [Link]:
Intent inten= new Intent(this,[Link]);
startActivity(inten);
break;
case [Link]:
Intent intentt= new Intent(this,[Link]);
startActivity(intentt);
break;
case [Link]:
Intent intenty= new Intent(this,[Link]);
startActivity(intenty);
break;
}
}
}
2. java class for cat

package [Link];

import [Link];

import [Link];

public class cat extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].cat_history);
}}

3. manifests

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


<manifest xmlns:android="[Link]
xmlns:tools="[Link]

<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/[Link]"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="[Link]" />

<category android:name="[Link]" />


</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