2012-01-01 66 views
1

你好,我想知道如何使用以下方法findViewById(int id)扩展Preference有所谓setProgress(int progress)定义的方法,它使用的方法findViewById,这样的方式在扩展PreferenceActivity我可以使用的方法setProgress(int progress)另一个类的类中。如此以来,方法findViewById如何是类android.view.View定义我想使用的方法。从另一个类自定义SeekBarPreference setProgress?

回答

0

你将不得不通过其中一个特定视图或活动的功能,或者如果setProgress功能也不是一成不变的,存储在类莫名其妙内部变量视图或活动。

+0

发现鉴于ID当你说通过'活动'你的意思是它的'背景'吗? – camelCaseD 2012-01-01 18:08:19

+0

不,上下文对象没有方法'findViewById' – 2012-01-02 01:06:36

0

,我发现这个网站上的答案: http://www.codeproject.com/Articles/163541/SeekBar-Preference

你可以使用

LayoutInflater inflater = (LayoutInflater) setContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
View view = inflater.inflate(R.layout.dialog_slider, null); 

,然后你可以使用

mSeekBar = (SeekBar) view.findViewById(R.id.seek_bar); 
相关问题