gpt4 book ai didi

android - EditText.getText().getLength() 包含提示时是否返回 0?

转载 作者:行者123 更新时间:2023-11-28 21:01:35 27 4
gpt4 key购买 nike

我有一些代码,但它没有按预期工作。我的逻辑好像没有错,所以我认为是实现错误。我的代码:

public boolean[] party_check(){
Date date_ET = new Date(party_dateET.getYear(), party_dateET.getMonth(), party_dateET.getDayOfMonth());///Date is deprecated,
///but easy to handle
///this is used to test the date contained in the datepicker, party_dateET. If it is before the day today, then it will not write,
///and a message is displayed

boolean[] return_array = new boolean[4];
///EditText party_titleET;
///EditText party_timeET;
///EditText party_dateET;
///EditText party_venueET;
return_array[0] = true;
if(party_titleET.getText().length() == 0){
return_array[1] = false;
return_array[0] = false;
}else{
return_array[1] = true;
}
if(date_ET.before(Calendar.getInstance().getTime()) == true){
return_array[2] = false;
return_array[0] = false;
///tests that the date entered is not invalid, ie. is in the future.
///not test for time. I could say that if time == 00:00, then don't run, or use a listener to check if it has changed,
///using a boolean value. But this would not really benefit the task much, so I haven't. It would also
///take more coding, and more complex coding.
}else{
return_array[2] = true;
}
if(party_venueET.getText().length() == 0){
return_array[3] = false;
return_array[0] = false;
}else{
return_array[3] = true;
}
return return_array;
///return_array[0] - 1st value in array - is used as toggle as to whether the party is ready or not.
///return_array[1-4] are used to indicate to the user which textbox is empty/ has a problem.



}

但是,当我返回 bool 数组时,它并没有按照我的预期执行。这用于测试用户是否已将文本值输入到 EditText 中。但是它没有按预期工作。是我的逻辑有问题,还是我执行的不对?感谢您的帮助!!

最佳答案

当您使用 getText() 时,不会返回提示。您可以使用 getHint()虽然。

关于android - EditText.getText().getLength() 包含提示时是否返回 0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21218723/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com