My application has 3 edit texts: first name, last name, birthday.

I disabled the keyboard for birthday (state hidden used in XML) and instead a DatePicker appears when it is clicked. However, after typing in the last name you could click next on the keyboard and it would go down to birthday causing the keyboard to appear again.

Within my XML I wrote for birthday edit text:

   <EditText
    android:id="@+id/birth"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/lastName"
    android:windowSoftInputMode="stateHidden"
    android:ems="10"
    android:hint="@string/birth" />

How can I make the next button have the datepicker appear instead of the keyboard?

Additionally, I use an OnClickListener for the datepicker to appear. When I touch the edit text field for birthday it does not show up until I click the field one more time. I tried using onTouchListener but that just makes the DatePicker appear twice (after I select the date the date picker screen appears again resetting the date I selected) How can I fix this?

public void onClick(View v) 
{
    DialogFragment calendar = new DatePickerFragment(){
       @Override
       public void onDateSet(DatePicker view, int year, int month, int day) {
            dob.setText("" + year + "-" + (month+1) + "-" + day);
       }
    };
    calendar.show(getFragmentManager(), "datePicker");
}

Related posts

Recent Viewed