Mad Practical 10
Mad Practical 10
Mad Practical 10
xmlns:tools="http://schemas.android.com/t android:layout_height="wrap_content"
ools" android:layout_margin="40dp"
android:layout_width="match_parent" android:layout_marginTop="184dp"
android:layout_height="match_parent"
android:background="#3F50AE" android:background="@drawable/edt_shape"
tools:context=".MainActivity"> android:ems="10"
android:hint="Enter your address"
<TextView
android:id="@+id/textView2" android:inputType="textPersonName"
android:padding="10dp"
android:layout_width="wrap_content" android:textColor="#070707"
android:textColorHint="#070707"
android:layout_height="wrap_content"
android:text="Register Here" app:layout_constraintEnd_toEndOf="parent"
android:textColor="#FFFFFF"
android:textSize="20sp" app:layout_constraintStart_toStartOf="par
android:textStyle="bold" ent"
app:layout_constraintBottom_toBottomOf="p app:layout_constraintTop_toBottomOf="@+id
arent" /edt4" />
app:layout_constraintLeft_toLeftOf="paren <RadioGroup
t" android:id="@+id/radioGroup"
android:layout_width="0dp"
app:layout_constraintRight_toRightOf="par
ent" android:layout_height="wrap_content"
android:layout_margin="40dp"
app:layout_constraintTop_toTopOf="parent" android:orientation="horizontal"
android:paddingTop="10dp"
app:layout_constraintVertical_bias="0.059 android:paddingBottom="10dp"
" /> app:flow_horizontalAlign="center"
app:flow_verticalAlign="center"
<EditText
android:id="@+id/edt1" app:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp"
app:layout_constraintStart_toStartOf="par
android:layout_height="wrap_content" ent"
android:layout_margin="40dp"
app:layout_constraintTop_toBottomOf="@+id
android:background="@drawable/edt_shape" /edt2">
android:ems="10"
android:hint="Enter your name" <RadioButton
android:id="@+id/rb1"
android:inputType="textPersonName" android:layout_width="100dp"
android:padding="10dp"
android:textColor="#070707" android:layout_height="wrap_content"
android:textColorHint="#070707"
android:background="@drawable/edt_shape"
app:layout_constraintEnd_toEndOf="parent" android:padding="10dp"
android:text="Male"
android:textColor="#0B0A0A"
android:textSize="18sp" /> app:layout_constraintTop_toBottomOf="@+id
/edt1" />
<RadioButton
android:id="@+id/rb2" <Button
android:layout_width="120dp" android:id="@+id/button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="60dp" android:layout_margin="55dp"
android:layout_marginTop="460dp"
android:background="@drawable/edt_shape" android:backgroundTint="#E91E63"
android:padding="10dp" android:padding="10dp"
android:text="Female" android:text="Register"
android:textColor="#000000" android:textSize="16sp"
android:textSize="18sp" /> android:textStyle="bold"
</RadioGroup>
app:layout_constraintEnd_toEndOf="parent"
<EditText
android:id="@+id/edt3" app:layout_constraintHorizontal_bias="0.4
android:layout_width="0dp" 95"
android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="par
android:layout_margin="40dp" ent"
android:background="@drawable/edt_shape" app:layout_constraintTop_toBottomOf="@+id
android:ems="10" /edt3" />
android:hint="Enter your birth
date"
android:inputType="date" </androidx.constraintlayout.widget.Constr
android:padding="10dp" aintLayout>
android:textColor="#020202"
android:textColorHint="#050505"
Java Code:-
app:layout_constraintEnd_toEndOf="parent"
package com.example.mad_practical_10_1;
app:layout_constraintStart_toStartOf="par
ent" import
androidx.appcompat.app.AppCompatActivity;
app:layout_constraintTop_toBottomOf="@+id
import android.os.Bundle;
/radioGroup" /> import android.view.View;
import android.widget.ArrayAdapter;
<EditText import android.widget.Button;
android:id="@+id/edt4" import android.widget.EditText;
android:layout_width="0dp" import android.widget.RadioButton;
import android.widget.Spinner;
android:layout_height="wrap_content" import android.widget.Toast;
android:layout_margin="40dp"
android:layout_marginTop="24dp" public class MainActivity extends
AppCompatActivity {
Button b1;
android:background="@drawable/edt_shape" EditText ed1,ed2;
android:ems="10" String s1,s2;
android:hint="Enter your phone
number" @Override
android:inputType="number" protected void onCreate(Bundle
android:padding="10dp" savedInstanceState) {
android:textColor="#090909" super.onCreate(savedInstanceState);
android:textColorHint="#090909"
setContentView(R.layout.activity_main);
app:layout_constraintEnd_toEndOf="parent" b1 = findViewById(R.id.button);
ed1 = findViewById(R.id.edt1);
app:layout_constraintStart_toStartOf="par ed2 = findViewById(R.id.edt2);
ent"
b1.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v) {
s1 =
String.valueOf(ed1.getText());
s2 =
String.valueOf(ed2.getText());
if (s1.equals("") ||
s2.equals("")){
Toast.makeText(MainActivity.this, "Please
enter your information",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "Register
Successfully", Toast.LENGTH_SHORT).show();
}
}
});
}
}
Output:-