3
獲取參考佈局我有一個偏好屏幕,包含自定義DialogPreference
:從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
財產應用佈局,這個自定義對話框。我想從我的DialogPreference
得到這個佈局中的TextView
參考,但我不知道從哪裏得到它:
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);
}
}