【发布时间】:2017-09-19 20:15:44
【问题描述】:
当您单击图像按钮时,会弹出弹出通知。如何自定义“确定”和“取消”按钮,而不是使用按钮的默认外观,我想使用自己的自定义 ImageButtons 作为“确定”和“取消”。
这是我的弹出通知代码。
public class Notifications extends AppCompatActivity {
ImageButton Notifications;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notifications);
Notifications = (ImageButton) findViewById(R.id.AllowNotifications);
Notifications.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(Notifications.this);
builder.setCancelable(false); //False= ONLY way to exist notification is by clicking NO
//True= Exit notification by clicking anywhere on screen outside of notification box.
builder.setTitle("Here is the alert dialog");
builder.setMessage("Here is my message thing");
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int WhichButton) {
dialog.cancel();
}
});
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
builder.show();
}
});
}
}
这是上面代码的默认弹出通知:
因此,我想将“ok”和“cancel”作为我自己的自定义图像按钮,而不是红色的“ok”和“cancel”,我想将颜色从红色更改为别的东西。如何在弹出通知中执行此操作?
【问题讨论】:
标签: android push-notification popupwindow android-imagebutton