Practical 7 code
Practical 7 code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Username"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Username"
android:hint="@string/Username"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Password"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Password"
android:hint="@string/Password"
android:inputType="textPassword"/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Submit"
android:id="@+id/Submit"
android:layout_gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Display"
android:text=""
android:layout_gravity="center"
android:textStyle="bold"
android:textSize="30sp"
android:textColor="@color/black"/>
</LinearLayout>
package com.example.edit;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
submit.setOnClickListener(v->{
String Username=username.getText().toString();
String Password=password.getText().toString();
display.setText(getString(R.string.Display,Username,Password));
}
);
}
}
2:-
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="10sp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Name"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Name"
android:hint="@string/Name"
android:inputType="textPersonName"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/DOB"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/DOB"
android:hint="@string/DOB"
android:inputType="date"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/BloodGroup"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/BloodGroup"
android:hint="@string/BloodGroup"/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Submit"
android:id="@+id/Submit"
android:layout_gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Display"
android:text=""
android:layout_gravity="center"
android:textStyle="bold"
android:textSize="30sp"
android:textColor="@color/black"/>
</LinearLayout>
package com.example.edit;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
submit.setOnClickListener(v->{
String Name=name.getText().toString();
String Dob=dob.getText().toString();
String BloodGroup=bloodGroup.getText().toString();
display.setText(getString(R.string.Display,Name,Dob,BloodGroup));
}
);
}
}