Missing buttons on AlertDialog | Android 7.0 (Nexus 5x)

前端 未结 9 1788
别那么骄傲
别那么骄傲 2020-12-05 13:19

I am trying to create an AlertDialog but the buttons are not showing. Only seeing this issue in Android 7.0:

final AlertDialog.Builder builder =         


        
9条回答
  •  不思量自难忘°
    2020-12-05 13:34

    Indeed it seems that AlertDialog theme needs to be defined. An alternative approach to above would be to define AlertDialog theme in Application theme:

    
    
    
    

    Then it is enough create AlertDialog.Builder only with Context parameter.

    Note: The above seems to work only for android.app.AlertDialog.Builder and is not working for AppCompat builder (android.support.v7.app.AlertDialog.Builder, at least as of version 25.0.1). In case of AppCompat builder, I had to pass theme ID as second parameter to Builder constructor to have buttons visible.

提交回复
热议问题