[Android]You need to use a Theme.AppCompat theme on AlertDialog creation

转自:http://stackoverflow.com/questions/34523384/you-need-to-use-a-theme-appcompat-theme-on-alertdialog-creation

Try to set Theme to your AlertDialog by replacing your line of code :

builderSingle =newAlertDialog.Builder(context);

with :

builderSingle =newAlertDialog.Builder(context,R.style.dialogTheme);

Add code in your style.xml :

<stylename="dialogTheme"parent="@style/Theme.AppCompat"><!-- Any customizations for your app running on devices with Theme.Holo here --></style>

and remember one thing to avoid Unable to add window -- token null is not for an application Exception Instead of getApplicationContext(), just use Activityname.this

猜你喜欢

转载自jameskaron.iteye.com/blog/2364500