メインアクティビティのデータをonCreateDialogのDialogFragmentのEditListNameDialogFragmentスーパーコンストラクタに渡して、これらの例外をスローしています。DialogFragmentの作成時にNullPointerExceptionが発生する
プロセス:com.example.zar.shoppinglistplusfirebase、PID:com.example.zar.shoppinglistplusfirebase.ui.activeListDetails.EditListDialogFragment.createDialogHepler(EditListDialogFragment.java:67)における32464 java.lang.NullPointerExceptionが android.support.v4.app.DialogFragment.getLayoutInflater(DialogFragment.java:312) でcom.example.zar.shoppinglistplusfirebase.ui.activeListDetails.EditListNameDialogFragment.onCreateDialog(EditListNameDialogFragment.java:47) でandroid.support.v4で.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298) ) android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323) android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136) android.support.v4.app .FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1998)の android.support.v4.app.FragmentManagerImpl $ 1.run(FragmentManager.java: 709) android.os.Handler.handleCallback(Handler.java:733) (android.os.Handler.dispatchMessage(Handler.java:95) ) android.os.Looper.loop(Looper.java:136) android.app.ActivityThread.main(ActivityThread.java:5590) at java.lang.reflect.Method.invokeNative(ネイティブメソッド) at java。 com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1268) at lang.reflect.Method.invoke dalvik.system.NativeStart.mainでZygoteInit.java:1084) (ネイティブメソッド)
onCreateDialogFragment F ROM EditListNameDialogFragment
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.createDialogHelper(R.string.positive_button_edit_item);
helpSetDefaultValueEditText(mListName);
return dialog;
}
super.createDialogHelper(文字列R)EditListDialogFragmentから
protected Dialog createDialogHepler(int stringResourceforPositiveButton){
AlertDialog.Builder builder=new AlertDialog.Builder(getActivity(),R.style.CustomTheme_Dialog);
LayoutInflater inflater=getActivity().getLayoutInflater();
View rootView=inflater.inflate(mResource,null);
mEditTextForList=(EditText) rootView.findViewById(R.id.edit_text_list_dialog);
mEditTextForList.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
if (i== EditorInfo.IME_ACTION_DONE || keyEvent.getAction()==KeyEvent.ACTION_DOWN){
doListEdit();
EditListDialogFragment.this.getDialog().cancel();
}
return true;
}
});
builder.setView(rootView).setPositiveButton(stringResourceforPositiveButton, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
doListEdit();
EditListDialogFragment.this.getDialog().cancel();
}
})
.setNegativeButton(R.string.negative_button_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
EditListDialogFragment.this.getDialog().cancel();
}
});
return builder.create();
}
他のダイアログでもこのcreateDialogHelperを使用していますが、他のダイアログでは完全に機能しますが、EditListNameDialogFragmentでは機能しません。 –