OnBindDialogView not called - why?

I am trying to implement a subclass of ListPreference and although its constructor called (when displayed), its overriden onBindDialogView is not.

public MyListPreference(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub Log.v(TAG, "MyListPreference constructed."); } @Override protected void onBindDialogView(View view) { super.onBindDialogView(view); Log.v(TAG, "onBindDialogView called"); } 

Why is this happening? What am I missing?

Update . I set the log message to onCreateDialogView () and also called.

Only onBindDialogView () , which is not called.

Why? What are the conditions for calling this callback?

+4
source share
1 answer

What returns your onCreateDialogView() ? onBindDialogView() is only called if you are returning a nonzero user view from it. In addition, onBindDialogView() is called only when you really show the preference. Link: DialogPreference source code . In particular, see the showDialog() Method

If you just return the super implementation from your onCreateDialogView() , I suspect that it returns null .

+5
source

Source: https://habr.com/ru/post/1487643/


All Articles