Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Preference with AndroidX Preference

Before AndroidX,
I would override the Preference's onCreateView(ViewGroup parent) method to pass Custom Layouts to be used as Preference.

But in AndroidX's Preference, there is no onCreateView(ViewGroup parent) method but it instead has onBindViewHolder(PreferenceViewHolder holder), I am not sure how to pass custom layouts & use them instead..

Any help would be highly appreciated!
Thanks!

like image 368
DarShan Avatar asked Sep 06 '25 08:09

DarShan


1 Answers

One has to assign it in the constructor already:

this.setLayoutResource(R.layout.preferences);

Here are some examples for onBindViewHolder().

like image 151
Martin Zeitler Avatar answered Sep 08 '25 07:09

Martin Zeitler