java - 如何创建一个根据时间隐藏其选择项的警报对话框
问题描述
我正在 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();
推荐阅读
- typescript - 在 Reactive forms angular 5 中使用 formarray 动态添加表单
- android - android 前台应用时每 5 秒更新一次状态
- spring-data-jpa - Spring with Querydsl:空指针异常
- sql - Sql 删除字符串中的子字符串(oracle 11g)
- compilation - 是否有工具可用于将 WebAssembly “组装”为 x86-64 本机代码?
- java - 解释用JAVA写的这一行
- r - grep multiple patterns Or condition on grouping data
- ios - How to set up UIScrollView programatically to scroll horizontally using autoLayout
- php - Laravel中效用函数的含义是什么
- angular - 角度 POS 打印问题