0

I have in a Android Application, a DialogFragment that is show, when I click on FloatingActionButton.

Now, this is the xml file of DialogFragment:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:focusable="true"
    android:focusableInTouchMode="true">

    <TextView
        android:id="@+id/labelStartDate"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:gravity="left|center"
        android:padding="15dp"
        android:text="@string/start_date"/>

    <DatePicker
        android:id="@+id/startDate"
        android:layout_width="wrap_content"
        android:layout_height="150dp"
        android:layout_toRightOf="@id/labelStartDate"
        android:calendarViewShown="false"
        android:datePickerMode="spinner"
        android:endYear="2100"
        android:startYear="1900"
        >
    </DatePicker>

    <TextView
        android:id="@+id/labelEndDate"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:gravity="left|center"
        android:padding="15dp"
        android:layout_below="@id/labelStartDate"
        android:text="@string/end_date"/>

    <DatePicker
        android:id="@+id/endDate"
        android:layout_width="wrap_content"
        android:layout_height="150dp"
        android:calendarViewShown="false"
        android:datePickerMode="spinner"
        android:layout_toRightOf="@id/labelEndDate"
        android:layout_below="@id/labelStartDate"
        android:paddingTop="10dp"
        android:endYear="2100"
        android:startYear="1900"
        >
    </DatePicker>

   ......
</RelativeLayout>

In my Fragment, I open the DialogFragment in this mode:

FloatingActionButton button = (FloatingActionButton) v.findViewById(R.id.add_button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertsDialogFragment dialog = AlertsDialogFragment.newInstance();
                dialog.show(getActivity().getFragmentManager(),"");
            }
        });

Now, whit this code, I'm able to display the Dialogfragment, but now I have two problems:

1) If I show, the Dialog, then I click on another point on the view, the Dialog is hide. 2) If I click on fourth (for example) editText, I can't click on the next EditText, and I must hide keyboard, then click on edittext...

EDIT

For the second point, when I display the DialogFragment, I see this: enter image description here

But if I click on the Reaction Text, I can't see the text Status as you can see from this image: enter image description here

bircastri
  • 2,169
  • 13
  • 50
  • 119

1 Answers1

0

1st point: use the method setCanceledOnTouchOutside(false) on dialog object

public void onClick(View v) {                 
AlertsDialogFragment dialog = AlertsDialogFragment.newInstance(); 
dialog.setCanceledOnTouchOutside(false);
dialog.show(getActivity().getFragmentManager(),"");            

}

other information here

2nd point: the query is not clear, anyway I try to deduce it: you want move to the next field(editText)

The solution is use a keyboard action in your editText, so you must add this attribute

android:imeOptions = actionNext

in your editText.

In this manner you still will not see the next focusable fields(editText), but the system applies the "actionNext" action to the current EditText when the user select Next(carriage return key) to move to the next field

you can find other informations about keyboard actions here

pask23
  • 714
  • 11
  • 20