根据时间更改文本视图
Change textview depending on time
我想根据日期和时间更改我的 TextView 内容,目前我有一个输出日期和时间的文本视图,我想要另一个文本视图来查看它,如果它大于 17:00 并且日期是 24/04/2016 然后它将文本更改为关闭。或者我可以使用我的文本视图查看的文本时钟吗?
// 显示当前日期和时间
TextView tv = (TextView) findViewById(R.id.textView4);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
String currentDateandTime = sdf.format(new Date());
tv.setText(currentDateandTime);
我想你需要这个:
txt1.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
// write the condition for second textview here
if(date.equals("24/04/2016") && time.equals("17:00"))
{
txt2.setText("closed");
}
}
});
我想根据日期和时间更改我的 TextView 内容,目前我有一个输出日期和时间的文本视图,我想要另一个文本视图来查看它,如果它大于 17:00 并且日期是 24/04/2016 然后它将文本更改为关闭。或者我可以使用我的文本视图查看的文本时钟吗?
// 显示当前日期和时间
TextView tv = (TextView) findViewById(R.id.textView4);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
String currentDateandTime = sdf.format(new Date());
tv.setText(currentDateandTime);
我想你需要这个:
txt1.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
// write the condition for second textview here
if(date.equals("24/04/2016") && time.equals("17:00"))
{
txt2.setText("closed");
}
}
});