> For the complete documentation index, see [llms.txt](https://sathyakumars-kb.gitbook.io/android-studio/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sathyakumars-kb.gitbook.io/android-studio/largest-of-three-numbers.md).

# Largest Of Three Numbers

## file -> new project&#x20;

<figure><img src="/files/EcwgjHjRD78BOIZH3iCc" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/0LinOvlGfM7qCxt9Tix8" alt=""><figcaption></figcaption></figure>

## App name

res -> values -> string.xml => App name: Largest of Three Numbers

## Color:

res -> values -> color.xml

```xml
<color name="white">#DC0A51</color>
```

## Drawable:

to create a shape.xml

```xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#000000" />

    <stroke android:width="10dp" android:color="#00FF00"/>

    <corners android:radius="5dp" />
</shape>
```

## Design

activity\_main.xml:

```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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="15dp">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textview1"
            android:text="@string/app_name"
            android:layout_margin="10dp"
            android:textSize="38dp"
            android:textAlignment="center"
            android:textColor="@color/pink"
            android:textStyle="bold" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_margin="15dp">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/textview2"
            android:text="Enter First Number: "
            android:textSize="20dp"/>

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/num1"
            android:paddingTop="15dp"
            android:paddingBottom="15dp"
            android:paddingLeft="15dp"
            android:textColor="@color/pink"
            android:textSize="30dp"
            android:background="@drawable/shape" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_margin="15dp">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/textview3"
            android:text="Enter Second Number: "
            android:textSize="20dp"/>

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/num2"
            android:paddingTop="15dp"
            android:paddingBottom="15dp"
            android:paddingLeft="15dp"
            android:textColor="@color/pink"
            android:textSize="30dp"
            android:background="@drawable/shape" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_margin="15dp">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/textview4"
            android:text="Enter third Number: "
            android:textSize="20dp"/>

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/num3"
            android:paddingTop="15dp"
            android:paddingBottom="15dp"
            android:paddingLeft="15dp"
            android:textColor="@color/pink"
            android:textSize="30dp"
            android:background="@drawable/shape" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_margin="0dp">

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/large"
            android:textColor="@color/white"
            android:textSize="20dp"
            android:text="LARGEST"
            android:textAlignment="center"
            android:layout_marginLeft="70dp"
            android:layout_marginRight="70dp"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="5dp">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/result"
            android:textColor="@color/purple_500"
            android:textSize="20dp"
            android:textAlignment="center"/>

    </LinearLayout>

</LinearLayout>
```

## Logic

MainActivity.java

```java
package com.example.largestnumber;

import androidx.appcompat.app.AppCompatActivity;

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

public class MainActivity extends AppCompatActivity {

    private EditText a;
    private EditText b;
    private EditText c;
    private TextView result;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        a = (EditText) findViewById(R.id.num1);
        b = (EditText) findViewById(R.id.num2);
        c = (EditText) findViewById(R.id.num3);
        Button large = (Button) findViewById(R.id.large);
        result = (TextView) findViewById(R.id.result);

        large.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int num1 = Integer.parseInt(a.getText().toString());
                int num2 = Integer.parseInt(b.getText().toString());
                int num3 = Integer.parseInt(c.getText().toString());

                if((num1 > num2) && (num1 > num3))
                    result.setText(num1+ " Number 1 is greater.");
                else if ((num2 > num1) && (num2 > num3))
                    result.setText(num2+" Number 2 is greater.");
                else
                    result.setText(num3+" Number 3 is greater.");

            }
        });

    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sathyakumars-kb.gitbook.io/android-studio/largest-of-three-numbers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
