InstantiationException when using subclass of EditTextPreference

前端 未结 2 602
醉酒成梦
醉酒成梦 2020-12-20 06:36

Assume, I have a subclass of EditTextPreference called PasswordProtectedEditTextPreference. This subclass basically shows a password dialog before one can edit

相关标签:
2条回答
  • 2020-12-20 06:47

    You created an abstract class:

      public abstract class PasswordProtectedEditTextPreference  
    

    No wonder it can't be instantiated ;-)

    0 讨论(0)
  • 2020-12-20 06:48

    Usually, that means that you do not have an appropriate constructor. Make sure that your constructor is public and takes a Context and AttributeSet as parameters:

    public TimePreference(Context ctxt, AttributeSet attrs)
    

    (from this custom preference from this sample project)

    0 讨论(0)
提交回复
热议问题