Using onClick attribute in layout xml causes a NoSuchMethodException in Android dialogs

后端 未结 9 1687
说谎
说谎 2020-11-29 07:45

I have created a custom dialog and a layout xml:




        
9条回答
  •  醉话见心
    2020-11-29 08:06

    A dialog is always created and displayed as part of an Activity. According to Android References:

    If you decide to create a dialog outside of the onCreateDialog() method, 
    it will not be attached to an Activity. You can, however, 
    attach it to an Activity with setOwnerActivity(Activity).

    Also, are you passing the object returned by getApplicationContext(); to the constructor of TestDialog?

提交回复
热议问题