How to Build AppCompatDialog From AlertDialog.Builder or Equivalent?

前端 未结 4 1626
无人及你
无人及你 2021-02-13 17:21

Before this I used a DialogBuilder to create AlertDialog like this

AlertDialog.Builder builder = new AlertDialog.Builder(context);
...
         


        
4条回答
  •  半阙折子戏
    2021-02-13 17:34

    If you would like to use an AlertDialog, just import the new supprt v 22.1 and use a code like this (pay attention to the import):

    import android.support.v7.app.AlertDialog
    
    AlertDialog.Builder builder =
           new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
                builder.setTitle("Dialog");
                builder.setMessage("Lorem ipsum dolor ....");
                builder.setPositiveButton("OK", null);
                builder.setNegativeButton("Cancel", null);
                builder.show();
    

    If

提交回复
热议问题