I have a custom DialogFragment whose layout holds just a EditText element.
Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/reminder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/reminder_message"
android:inputType="text" />
</LinearLayout>
Code:
public class ReminderDialog extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_reminder, container, false);
return rootView;
}
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
if (onDismissListener != null) {
String text = (String) ((TextView) (rootView.findViewById(R.id.reminder))).getText();
onDismissListener.onDismiss(text);
}
}
It is working fine in app module. But I want to take into library module. But then I debugged the error, it is because R.id.reminder is 0.
Is there anyway to access the element.