【发布时间】:2010-07-11 13:31:36
【问题描述】:
如何找到我的 PreferenceActivity 实例,它是由框架创建的?
* * *
我的第一堂课。
/** This is MyAppSettings class, The instance of this class will be created by a framework **/
public class MyAppSettings extends PreferenceActivity {
protected MySeekBarPreference mSeekBarPref;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs);
mSeekBarPref = (MySeekBarPreference)super.findPreference("my_key");
}
}
* * *
我的第二节课。
public class MySeekBarPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener {
// in whis code I need to get the instance of the MyAppSettings, which was
// created by Android framework. (I paste a hypothetical func getTheInstanceOfMyAppSettings() :))
private MyAppSettings mAppSettings = getTheInstanceOfMyAppSettings();
我可以通过 ID 或其他方式找到它吗?
【问题讨论】:
-
在哪里,怎么做?在您的上下文中可能是
this。请编辑您的原始问题,并发布您如何创建的详细代码,以及您想在哪里找到实例。
标签: android frameworks preferenceactivity