Custom preference, targetSdkVersion=“11”: missing indent?

后端 未结 5 1154
既然无缘
既然无缘 2020-12-14 18:49

I have a couple of custom DialogPreference implementations floating around, such as this one:

package apt.tutorial;

import android.content.Cont         


        
5条回答
  •  失恋的感觉
    2020-12-14 19:15

    The solution which helped me:

    I have replaced

    public TimePreference(Context ctxt, AttributeSet attrs) {
        this(ctxt, attrs, 0);
    }
    

    with

    public TimePreference(Context ctxt, AttributeSet attrs) {
        this(ctxt, attrs, ctxt.getResources().getSystem().getIdentifier("dialogPreferenceStyle", "attr", "android"));
    }
    

    As you can see, I replaced third argument 0 with ctxt.getResources().getSystem().getIdentifier("dialogPreferenceStyle", "attr", "android") in the second constructor of custom preference class.

提交回复
热议问题