Making Register Form – Using ScrollView,Spinner,DatePickerDialog,RadioGroup

In this tutorial, we will make a register form.

  • Start a new project. Project name is up to you, I named it as RegisterForm. If you forget how to open new project in android studio, follow this.


  • First of all, you need to define all resources which are used by application.
    Open your res/values/strings.xml file and add below string items.


  • Lets design the screen. Open your res/layout/activity_main.xml file and write below.


    As you see above layout code, a ScrollView wraps a LinearLayout and that LinearLayout contains all form elements. ScrollView can not have more than one child element. What the child element is doesn’t matter. It can be a RelativeLayout, a LinearLayout or a TextView. Important thing is that if we have more than one scrollable element, we need to cover them with a container layout before adding them to the ScrollView.

  • You can look at how it looks with switching to design mode.Screen Shot 2015-12-14 at 16.05.58


  • So we have everything for design lets go to java side. Open your MainActivity.javaBind all view with their ids.


  • We want birthdayEdittext and registerButton as clickable. Our MainActivity should be a OnClickListener and we need to implement onClick method. Then we declare what happens when birthdayEdittext and registerButton is clicked in onClick method.


  • Lets create our calendar to show when users select their birthdays. We use DatePickerDialog to represent a calendar. It is defined on Android. You don’t have to implement an extra thing.


  • And finally we need to show a toast with typed or selected values when user clicks on registerButton. We should check if any field is empty.

  • Thats all. You can run the application. See you next tutorial.
download_source_icon Download Source Code
If you don’t know how to open an existing Android Studio Project, follow this tutorial.

Bir Cevap Yazın