레이아웃이 EditText 요소 만 포함하는 사용자 정의 DialogFragment가 있습니다.DialogFragment 레이아웃의 뷰 요소는 id로 액세스 할 수 없습니다.
레이아웃 :
<?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>
코드 :
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);
}
}
그것은 응용 프로그램 모듈에서 잘 작동한다. 그러나 나는 도서관 모듈에 들어가기를 원한다. 하지만 그때 나는 오류를 디버깅했습니다. 그것은 R.id.reminder가 0이기 때문입니다.
어쨌든 요소에 액세스 할 수 있습니까?
뭘 하시겠습니까? ondismiss에서 액세스하는 이유 –
지도 마커의 InfoWindow를 길게 누르면 EditText 요소가있는 DialogFragment가 열립니다. 제출 버튼을 원하지 않습니다. 사용자가 대화 상자를 닫으면 InfoWindow에 텍스트가 설정됩니다. –