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

后端 未结 3 1567
我寻月下人不归
我寻月下人不归 2021-02-10 15:12

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:31

    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) {
        }
    }
    

提交回复
热议问题