我有一个包含自定义的首选项屏幕DialogPreference
:
<com.company.project.AboutDialog
android:key="about_dialog"
android:icon="@drawable/logo"
android:title="About Company Project"
android:summary="Version information"
android:dialogLayout="@layout/about_dialog"
android:negativeButtonText=""
/>
如您所见,我正在使用该dialogLayout
属性将布局应用于此自定义对话框。TextView
我想从我的这个布局中获得对 a 的引用,DialogPreference
但我不知道从哪里得到它:
public class AboutDialog extends DialogPreference {
@Override
protected void onPrepareDialogBuilder(Builder builder) {
// Hide the title from the dialog
builder.setTitle(null);
super.onPrepareDialogBuilder(builder);
/*
* Where do I find a context for findViewById?
* ((TextView)findViewById(R.id.version)).setText("Hello, world");
*/
}
public AboutDialog(Context context, AttributeSet attrs) {
super(context, attrs);
}
}