I have a couple of custom DialogPreference
implementations floating around, such as this one:
package apt.tutorial;
import android.content.Cont
You can dance with void Preference.setWidgetLayoutResource(int widgetLayoutResId)
method, although I prefer to override View Preference.onCreateView(ViewGroup parent)
method in my custom Preference class and hack it by adding custom views just below @android:id/summary
(use hierarchyviewer utility for details).
The complete method is:
@Override
protected View onCreateView(ViewGroup parent)
{
View ret = super.onCreateView(parent);
View summary = ret.findViewById(android.R.id.summary);
if (summary != null)
{
ViewParent summaryParent = summary.getParent();
if (summaryParent instanceof ViewGroup)
{
final LayoutInflater layoutInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup summaryParent2 = (ViewGroup) summaryParent;
layoutInflater.inflate(R.layout.seek_bar_preference, summaryParent2);
seekBar = (SeekBar) summaryParent2.findViewById(R.id.seekBar);
seekBar.setMax(maxValue - minValue);
seekBar.setOnSeekBarChangeListener(this);
statusText = (TextView) summaryParent2.findViewById(R.id.seekBarPrefValue);
unitsRightView = (TextView) summaryParent2.findViewById(R.id.seekBarPrefUnitsRight);
unitsLeftView = (TextView) summaryParent2.findViewById(R.id.seekBarPrefUnitsLeft);
}
}
return ret;
}
Source code of my SeekBarPreference class based on code from http://robobunny.com can be downloaded here