12 ActionPreference - michael-rapp/AndroidMaterialPreferences GitHub Wiki
The preference ActionPreference
is intended to be used as a button, which performs an action when clicked. In order to observe, when the preference is clicked, the classes' setOnPreferenceClickListener
-method has to be used. The title of the preference is displayed centered. When setting an icon, it is shown next to the title. Because no dialog is shown when clicking the preference, the getter- and setter-methods, respectively XML attributes, which have been mentioned in section "Common properties" of this documentation, are not supported by this preference.
12.1 Getter and setter methods
The class ActionPreference
provides the following setter and getter methods.
Getter and setter methods | Description | Default value | Restrictions |
---|---|---|---|
getTitle():CharSeqence() setTitle(CharSequence):void setTitle(int):void |
Returns or sets the preference's title. | null |
When specified as a resource ID, the ID must correspond to a valid string resource |
getIcon():Drawable setIcon(Drawable):void setIcon(int):void |
Returns or sets the preference's icon. | null |
When specified as a resource ID, the ID must correspond to valid drawable resource |
getTextColor():int setTextColor(int):void |
Returns or sets the text color of the preference's title. | R.attr.colorAccent |
none |
getDisabledTextColor():int setDisabledTextColor(int):void |
Returns or sets the text color of the preference's title when disabled. | null | #42000000 |
12.2 XML attributes
As an alternative to the previously mentioned getter and setter methods, the following XML attributes can be used in order to specify the properties of an ActionPreference
.
XML attribute | Description | Format |
---|---|---|
android:title |
The preference's title. | string |
android:icon |
The preference's icon. | drawable |
android:textColor |
The text color of the preference's title. | color |
custom:disabledTextColor |
The text color of the preference's title when disabled. | color |