gpt4 book ai didi

java - 我如何编写代码让用户不选择任何内容或选择时间?

转载 作者:行者123 更新时间:2023-11-30 00:07:45 24 4
gpt4 key购买 nike

我想从 edittext 中为用户编写两个选项,要么不输入任何内容(这意味着无需设置提醒日期),要么通过 datePickerDialog 选择时间提醒。我该如何实现?

这是我的 edittext 添加时间的代码:

addtime.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
datePickerDialog.show();
return false;
}
});

最佳答案

把这个edittextunfocused.xml放在drawable文件夹里

<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke android:color="@color/grey"
android:width="@dimen/twoDp"/>
<corners android:radius="@dimen/twoDp"></corners>
</shape>

并用这个代替你的 EditText

<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/edittextunfocused"
android:text="Add Time"
android:id="@+id/addtime"

/>

关于java - 我如何编写代码让用户不选择任何内容或选择时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48688394/

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