I am writing a custom preference with a seek bar, so far it works, except for one problem the ID of my seek bar is defined in XML, so when I try to use 2 of my custom prefernces and then I update the Seek Bar I cannot distinguish between the two.
SeekBar bar = (SeekBar)view.findViewById(R.id.PreferenceSeekBar);
Is there a way to generate a custom Resource ID at runtime?
Or perhaps another way to solve this?
Thanks,
Jason
There is no
onBind()method onPreference. There is anonBindView()method. However, theViewpassed toonBindView()is whateverViewyou returned fromonCreateView(), or theViewinflated from your specified layout file if you went that route. It is not the entire activity.Make sure you are calling
findViewById()on the widget that was created for yourPreference, not something with broader scope.Also, bear in mind that
PreferenceActivityis aListActivity. If your customPreferencescrolls off the screen, itsViewmay be handed to another instance of your customPreferencefor recycling.