Ex 4
Ex 4
AIM: Create a screen that has input boxes for User Name, Password, Address, Gender(radio
buttonsfor male and female), Age (numeric), Date of Birth (Date Picket), State (Spinner) and a
Submit button. On clicking the submit button, print all the data below the Submit Button (use
any layout)..
Step 1: Create a New Project
activity_main.xml file
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton
android:id="@+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"/>
</RadioGroup>
package com.example.userdetailsapp;
import androidx.appcompat.app.AppCompatActivity;
import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import java.util.Calendar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// References to UI elements
EditText editTextUserName = findViewById(R.id.editTextUserName);
EditText editTextPassword = findViewById(R.id.editTextPassword);
EditText editTextAddress = findViewById(R.id.editTextAddress);
RadioGroup radioGroupGender = findViewById(R.id.radioGroupGender);
EditText editTextAge = findViewById(R.id.editTextAge);
EditText editTextDob = findViewById(R.id.editTextDob);
Spinner spinnerState = findViewById(R.id.spinnerState);
Button buttonSubmit = findViewById(R.id.buttonSubmit);
TextView textViewResult = findViewById(R.id.textViewResult);
textViewResult.setText(result);
});
}
}
Step 3: Run and Test
OUTPUT: