New AlertDialog library with appCampat v22.1

http://stackoverflow.com/questions/26455919/material-design-not-styling-alert-dialogs

http://developer.android.com/reference/android/support/v7/app/AlertDialog.html

 

<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
     <item name="colorAccent">#5fa3d0</item>
     <item name="android:textColorPrimary">#000000</item>
     <item name="android:background">#FFFFFF</item>
</style>
 
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
     builder.setTitle("Titttle");
     builder.setMessage("Yap, Message");
     builder.setPositiveButton("OK", null);
     builder.setNegativeButton("Cancel", null);
     builder.show();

For this, make sure you have following (v22 or higher) in build.gradle

dependencies {
    compile 'com.android.support:appcompat-v7:23.2.1'
}
Advertisements

Published by