Professional Documents
Culture Documents
Code:
Input:
<?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:orientation="horizontal">
Page No-1
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Color"
android:textSize="20sp" />
<EditText
android:id="@+id/e1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="73dp"
android:layout_height="wrap_content"
Page No-2
android:text=" "
android:textSize="20sp" />
<EditText
android:id="@+id/e2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Page No-3
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="center"
android:text="Green" />
<Button
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="Red" />
<Button
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="center"
android:text="Blue" />
</LinearLayout>
</LinearLayout>
Page No-4
package com.example.imageandcolor;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.EditText;
EditText e1,e2;
Button b1,b2,b3 = findViewById(R.id.b3);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e1=findViewById(R.id.e1);
e2=findViewById(R.id.e2);
b1=findViewById(R.id.b1);
Page No-5
b2=findViewById(R.id.b2);
b3=findViewById(R.id.b3);
}
bu1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
b1.setBackgroundColor(Color.GREEN);
text.setTextColor(Color.GREEN);
b2.setBackgroundColor(Color.LTGRAY);
b3.setBackgroundColor(Color. LTGRAY);
}});
Page No-6
Output:
Discussion:
This is my second work simple list app using android studio. It
is very interested for me. Here, I am used many commands
Linear Layout, Button, Text.
I am very happy to complete this work properly.
Page No-7