如何创建一个根据时间隐藏其选择项的警报对话框
How to create an alertdialog that hides its choice items depending on time
我正在 android 中实现一个 singleChoiceItems 警报对话框,但我想进行检查,以便数组中的某些项目不会根据时间显示。
这可能吗,或者我可以使用任何方法代替警报对话框吗?
如果"true",这是一个如何检查时间和更改项目的简单示例。
对话框是一个对象,可以通过在不同位置调用biulder.*来调用它的属性。
String[] colurs ={"Red","Blue","Green"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick Colour")
.setItems(colurs, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
}
});
if(currentThreadTimeMillis()>1000){
colurs[0]="New1";
colurs[1]="New2";
builder.setTitle("Pick Colour").setItems(colurs, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
}
});
}
builder.create();
builder.show();
我正在 android 中实现一个 singleChoiceItems 警报对话框,但我想进行检查,以便数组中的某些项目不会根据时间显示。
这可能吗,或者我可以使用任何方法代替警报对话框吗?
如果"true",这是一个如何检查时间和更改项目的简单示例。 对话框是一个对象,可以通过在不同位置调用biulder.*来调用它的属性。
String[] colurs ={"Red","Blue","Green"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick Colour")
.setItems(colurs, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
}
});
if(currentThreadTimeMillis()>1000){
colurs[0]="New1";
colurs[1]="New2";
builder.setTitle("Pick Colour").setItems(colurs, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
}
});
}
builder.create();
builder.show();