问题
I found this nice custom progress dialog box: https://github.com/d-max/spots-dialog
and am using it as follows inside onClick
function of the fragment (as connection to remote device is made on a button press):
AlertDialog dialog = new SpotsDialog(parentActivity, R.style.custom_dialog);
dialog.show();
//bluetooth time consuming code.
dialog.dismiss();
parentActivity.loadFragment(DrawerActivity.Fragments.FILE_BROWSER, bundle, true);
I have defined the following in styles.xml
:
<style name="custom_dialog" parent="android:Theme.DeviceDefault.Dialog">
<item name="DialogTitleAppearance">@android:style/TextAppearance.Medium</item>
<item name="DialogTitleText">Updating…</item>
<item name="DialogSpotColor">@android:color/holo_orange_dark</item>
<item name="DialogSpotCount">4</item>
</style>
Updated the dependencies as follows as per instructions given on the github page:
dependencies {
compile 'com.github.d-max:spots-dialog:0.4@aar'
}
I am not sure what I am missing. Any help appreciated.
EDIT: Adding relevant component from gradle:
android { compileSdkVersion 23 buildToolsVersion "21.1.2"
defaultConfig {
applicationId "edu.unm.twin_cities.graphit"
minSdkVersion 15
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
回答1:
- You're API level must be a higher then 15.
- On the pre-lollipop devices DialogSpotColor item won't work. As workaround just override color in your resources. Your max level API is 16, lollipop its 21 and higher.
Try throw away the DialogSpotColor item from your style.
<style name="custom_dialog" parent="android:Theme.DeviceDefault.Dialog">
<item name="DialogTitleAppearance">@android:style/TextAppearance.Medium</item>
<item name="DialogTitleText">Updating…</item>
<item name="DialogSpotCount">4</item>
And add this line into your colors.xml:
<color name="spots_dialog_color">@android:color/holo_red_light</color>
来源:https://stackoverflow.com/questions/34949634/custom-progress-dialog-not-working