I have a custom DialogFragment which has an ArrayAdapter in it which has some editTexts in it. When the dialog is shown the soft keyboard does not appear even if i press on
I have come across a similar problem while using a FragmentDialog
containing a ListView
. The items in the ListView
contained EditText
widgets that did not bring up the soft keyboard.
A workaround I discovered was to place an invisible EditText
within the root layout of the FragmentDialog
.
For example:
list_layout.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@android:id/list"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
</LinearLayout>
DialogFragment creates the views as follows:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
LayoutInflater inflater = getActivity().getLayoutInflater();
View listLayout = inflater.inflate(R.layout.list_layout, null);
mListView = (ListView) listLayout.findViewById(android.R.id.list);
return new AlertDialog.Builder(getActivity()).setView(listLayout).create();
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
//set adapter
mListView.setAdapter(mListAdapter);
}
Hope this helps
set block descendants property true of your list_item_layout file.. i hope it helps