android DialogFragment android:onClick=“buttonCancel” causes IllegalStateException could not find a method

后端 未结 3 1147
死守一世寂寞
死守一世寂寞 2021-02-10 15:06

I have a problem with my Dialog Fragment. I wanted to use android:onClick attribute as in my opinion code is more clear then.

In my layout I have the following declarati

3条回答
  •  抹茶落季
    2021-02-10 15:32

    Try:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView (inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.dialog_new_database, container);    
        getDialog().setTitle("Hello");
        return view;
    
        private void buttonCancel (View view) {
        dismiss();
        }
        private void buttonOK (View view) {
        }
    }
    

提交回复
热议问题