public abstract class DialogPreference
extends Preference
| java.lang.Object | ||
| android.support.v7.preference.Preference | ||
| android.support.v7.preference.DialogPreference | ||
| |
| |
基于对话框的Preference对象的基类。 点击后,这些首选项将打开一个对话框,显示实际的首选项控制。
Nested classes |
|
|---|---|
interface |
DialogPreference.TargetFragment
|
Inherited constants |
|---|
android.support.v7.preference.Preference
|
Public constructors |
|
|---|---|
DialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) |
|
DialogPreference(Context context, AttributeSet attrs, int defStyleAttr) |
|
DialogPreference(Context context, AttributeSet attrs) |
|
DialogPreference(Context context) |
|
公共方法(Public methods) |
|
|---|---|
Drawable |
getDialogIcon() 返回后续对话框中显示的图标。 |
int |
getDialogLayoutResource() 返回用作后续对话框的内容视图的布局资源。 |
CharSequence |
getDialogMessage() 返回将在后续对话框中显示的消息。 |
CharSequence |
getDialogTitle() 返回后续对话框中显示的标题。 |
CharSequence |
getNegativeButtonText() 返回后续对话框中显示的否定按钮的文本。 |
CharSequence |
getPositiveButtonText() 返回在后续对话框中显示的肯定按钮的文本。 |
void |
setDialogIcon(int dialogIconRes) 设置对话框的图标(资源ID)。 |
void |
setDialogIcon(Drawable dialogIcon) 设置对话框的图标。 |
void |
setDialogLayoutResource(int dialogLayoutResId) |
void |
setDialogMessage(CharSequence dialogMessage) 设置对话框的消息。 |
void |
setDialogMessage(int dialogMessageResId) |
void |
setDialogTitle(int dialogTitleResId) |
void |
setDialogTitle(CharSequence dialogTitle) 设置对话框的标题。 |
void |
setNegativeButtonText(CharSequence negativeButtonText) 设置对话框的负面按钮的文本。 |
void |
setNegativeButtonText(int negativeButtonTextResId) |
void |
setPositiveButtonText(int positiveButtonTextResId) |
void |
setPositiveButtonText(CharSequence positiveButtonText) 设置对话框的正面按钮的文本。 |
Protected methods |
|
|---|---|
void |
onClick() 处理点击偏好。 |
继承方法(Inherited methods) |
|
|---|---|
android.support.v7.preference.Preference
|
|
java.lang.Object
|
|
java.lang.Comparable
|
|
DialogPreference (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
| 参数(Parameters) | |
|---|---|
context |
Context
|
attrs |
AttributeSet
|
defStyleAttr |
int
|
defStyleRes |
int
|
DialogPreference (Context context, AttributeSet attrs, int defStyleAttr)
| 参数(Parameters) | |
|---|---|
context |
Context
|
attrs |
AttributeSet
|
defStyleAttr |
int
|
DialogPreference (Context context, AttributeSet attrs)
| 参数(Parameters) | |
|---|---|
context |
Context
|
attrs |
AttributeSet
|
Drawable getDialogIcon ()
返回后续对话框中显示的图标。
| 返回(Returns) | |
|---|---|
Drawable |
The icon, as a Drawable. |
int getDialogLayoutResource ()
返回用作后续对话框的内容视图的布局资源。
| 返回(Returns) | |
|---|---|
int |
The layout resource. |
CharSequence getDialogMessage ()
返回将在后续对话框中显示的消息。
| 返回(Returns) | |
|---|---|
CharSequence |
The message. |
CharSequence getNegativeButtonText ()
返回后续对话框中显示的否定按钮的文本。
| 返回(Returns) | |
|---|---|
CharSequence |
The text of the negative button. |
CharSequence getPositiveButtonText ()
返回在后续对话框中显示的肯定按钮的文本。
| 返回(Returns) | |
|---|---|
CharSequence |
The text of the positive button. |
void setDialogIcon (int dialogIconRes)
设置对话框的图标(资源ID)。 这将在随后的对话框中显示。
| 参数(Parameters) | |
|---|---|
dialogIconRes |
int: The icon, as a resource ID. |
void setDialogIcon (Drawable dialogIcon)
设置对话框的图标。 这将在随后的对话框中显示。
| 参数(Parameters) | |
|---|---|
dialogIcon |
Drawable: The icon, as a Drawable. |
void setDialogLayoutResource (int dialogLayoutResId)
将设置为 View充气布局资源显示为后续对话框的内容视图。
| 参数(Parameters) | |
|---|---|
dialogLayoutResId |
int: The layout resource ID to be inflated. |
void setDialogMessage (CharSequence dialogMessage)
设置对话框的消息。 这将在随后的对话框中显示。
例如,此消息形成对话框的内容视图并与基于列表的对话框发生冲突。 如果通过setDialogLayoutResource(int)在对话框上设置自定义视图,请包含一个ID为message的文本视图,该视图将填充此消息。
| 参数(Parameters) | |
|---|---|
dialogMessage |
CharSequence: The message. |
void setDialogMessage (int dialogMessageResId)
| 参数(Parameters) | |
|---|---|
dialogMessageResId |
int: The dialog message as a resource. |
void setDialogTitle (int dialogTitleResId)
| 参数(Parameters) | |
|---|---|
dialogTitleResId |
int: The dialog title as a resource. |
也可以看看:
void setDialogTitle (CharSequence dialogTitle)
设置对话框的标题。 这将在随后的对话框中显示。
| 参数(Parameters) | |
|---|---|
dialogTitle |
CharSequence: The title. |
void setNegativeButtonText (CharSequence negativeButtonText)
设置对话框的负面按钮的文本。 这将在随后的对话框中显示。
| 参数(Parameters) | |
|---|---|
negativeButtonText |
CharSequence: The text of the negative button. |
void setNegativeButtonText (int negativeButtonTextResId)
| 参数(Parameters) | |
|---|---|
negativeButtonTextResId |
int: The negative button text as a resource. |
void setPositiveButtonText (int positiveButtonTextResId)
| 参数(Parameters) | |
|---|---|
positiveButtonTextResId |
int: The positive button text as a resource. |
void setPositiveButtonText (CharSequence positiveButtonText)
设置对话框的正面按钮的文本。 这将在随后的对话框中显示。
| 参数(Parameters) | |
|---|---|
positiveButtonText |
CharSequence: The text of the positive button. |
void onClick ()
处理点击偏好。 这包括将值保存到SharedPreferences 。 但是,重写的方法应该调用callChangeListener(Object)以确保客户端想要用新值更新首选项的状态。