2017-01-07 192 views
0

我有一個alertdialog框,其中我已經爲alertdialog按鈕定製了背景。在這個我想添加一個按鈕效果點擊任何人都可以告訴我我如何爲alertdialog添加按鈕點擊效果以及如何更改警報對話框中按鈕的大小。如何在alertdialog按鈕中添加按鈕點擊效果android

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
      NewDaybook_Activity.this); 

    // set title 
    alertDialogBuilder.setTitle(R.string.app_name); 

    // set dialog message 
    alertDialogBuilder 
      .setMessage(R.string.clickyestoexit) 
      .setCancelable(false) 
      .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int id) { 
        // if this button is clicked, close 
        // current activity 
        Intent a = new Intent(Intent.ACTION_MAIN); 
        a.addCategory(Intent.CATEGORY_HOME); 
        a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
        startActivity(a); 
       } 
      }) 
      .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int id) { 
        // if this button is clicked, just close 
        // the dialog box and do nothing 
        dialog.cancel(); 
       } 
      }); 

    // create alert dialog 
    AlertDialog alertDialog = alertDialogBuilder.create(); 

    // show it 
    alertDialog.show(); 
    Button nbutton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); 
    nbutton.setTextColor(getResources().getColor(R.color.colorAccent)); 
    Button pbutton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); 
    pbutton.setBackgroundColor(getResources().getColor(R.color.colorAccent)); 
    pbutton.setPadding(0, 10, 10, 0); 
    pbutton.setTextColor(Color.WHITE); 

enter image description here

+0

Onclick已經添加了兩個按鈕你想要做什麼請解釋 –

+0

@santoshkumar當我們點擊按鈕我想顯示按鈕的漣漪效應 –

回答

0

紋波效應已經存在上述奇巧版本, 對於預奇巧版本使用此library爲連鎖反應。

相關問題