So, I solved this problem earlier thanks to the help of another thread, but due to some new changes in my application, the previous solution no longer works. Here's the previous thread: Android app: replace the default button background with the custom background in the dialog snippet
I am trying to style backlinks to the positive / negative buttons of a DialogFragment user dialog and it seems that it cannot change it. I originally used the following:
@Override
public void onStart() {
super.onStart();
Button pButton = ((AlertDialog) getDialog()).getButton(DialogInterface.BUTTON_POSITIVE);
Button nButton = ((AlertDialog) getDialog()).getButton(DialogInterface.BUTTON_NEGATIVE);
pButton.setBackground(getResources().getDrawable(R.drawable.button_custom));
nButton.setBackground(getResources().getDrawable(R.drawable.button_custom));
}
It worked perfectly and did exactly what I wanted. However, I think this stopped working because I recently added a style created by the Android Action Bar styles generator, which can be found here: http://jgilfelt.imtqy.com/android-actionbarstylegenerator
I tried adding my styles to the style file generated by the action bar style generator, but this does not work. Here I tried to add:
<style name="ButtonLegacyButton" parent="android:Widget.Holo.Light.Button">
<item name="android:background">@drawable/legacybutton_btn_default_holo_light</item>
</style>
<style name="ImageButtonLegacyButton" parent="android:Widget.Holo.Light.ImageButton">
<item name="android:background">@drawable/legacybutton_btn_default_holo_light</item>
</style>
These are the new drawings that I created using http://android-holo-colors.com/
No software trick that I am trying to use in the onStart method seems to make anything stick to the buttons.
: http://android.codeandmagic.org/why-android-dialogfragment-confuses-me-part1/#comment-28043, , , .
, ?
EDIT:
style.xml, . .
Android:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.legacy"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/legacy_icon"
android:label="@string/app_name"
android:theme="@style/Theme.Legacylogo">
<activity
android:name="com.example.legacy.GameListActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
... other activities
</application>
</manifest>
styles_legacylogo.xml:
<resources>
<style name="Theme.Legacylogo" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarItemBackground">@drawable/selectable_background_legacylogo</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Legacylogo</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Legacylogo</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Legacylogo</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Legacylogo</item>
<item name="android:actionBarStyle">@style/ActionBar.Transparent.Legacylogo</item>
<item name="android:actionModeBackground">@drawable/cab_background_top_legacylogo</item>
<item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_legacylogo</item>
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Legacylogo</item>
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">@style/SpinnerItem.DropDownItem</item>
</style>
<style name="ActionBar.Solid.Legacylogo" parent="@android:style/Widget.Holo.ActionBar.Solid">
<item name="android:background">@drawable/ab_solid_legacylogo</item>
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_legacylogo</item>
<item name="android:backgroundSplit">@drawable/ab_bottom_solid_legacylogo</item>
<item name="android:progressBarStyle">@style/ProgressBar.Legacylogo</item>
</style>
<style name="ActionBar.Transparent.Legacylogo" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@drawable/ab_transparent_legacylogo</item>
<item name="android:progressBarStyle">@style/ProgressBar.Legacylogo</item>
</style>
<style name="PopupMenu.Legacylogo" parent="@android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_legacylogo</item>
</style>
<style name="DropDownListView.Legacylogo" parent="@android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_legacylogo</item>
</style>
<style name="ActionBarTabStyle.Legacylogo" parent="@android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_legacylogo</item>
</style>
<style name="DropDownNav.Legacylogo" parent="@android:style/Widget.Holo.Spinner">
<item name="android:background">@drawable/spinner_background_ab_legacylogo</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_legacylogo</item>
<item name="android:dropDownSelector">@drawable/selectable_background_legacylogo</item>
</style>
<style name="ProgressBar.Legacylogo" parent="@android:style/Widget.Holo.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_legacylogo</item>
</style>
<style name="ActionButton.CloseMode.Legacylogo" parent="@android:style/Widget.Holo.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_legacylogo</item>
</style>
<style name="SpinnerItem" parent="@android:style/Widget.TextView.SpinnerItem">
<item name="android:textColor">#fef7e7</item>
</style>
<style name="SpinnerItem.DropDownItem" parent="@android:style/Widget.DropDownItem.Spinner">
<item name="android:textColor">#fef7e7</item>
</style>
<style name="ButtonLegacyButton" parent="android:Widget.Holo.Light.Button">
<item name="android:background">@drawable/legacybutton_btn_default_holo_light</item>
</style>
<style name="ImageButtonLegacyButton" parent="android:Widget.Holo.Light.ImageButton">
<item name="android:background">@drawable/legacybutton_btn_default_holo_light</item>
</style>
<style name="Theme.Legacylogo.Widget" parent="@android:style/Theme.Holo">
<item name="android:popupMenuStyle">@style/PopupMenu.Legacylogo</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Legacylogo</item>
</style>
</resources>