Android 从Edittext到DayDecorator获取日期
首先感谢您阅读本文:) 这是我的问题 我得到了一个EditText(用户日期输入),我想使用DayDecorator在我的CustomCalander上获得当天的彩色背景Android 从Edittext到DayDecorator获取日期,android,android-edittext,getdate,Android,Android Edittext,Getdate,首先感谢您阅读本文:) 这是我的问题 我得到了一个EditText(用户日期输入),我想使用DayDecorator在我的CustomCalander上获得当天的彩色背景 //EditText I want to get the date huablauf = (EditText)getActivity().findViewById(R.id.huablauf); //adding calendar day decorators List<DayDecorator> deco
//EditText I want to get the date
huablauf = (EditText)getActivity().findViewById(R.id.huablauf);
//adding calendar day decorators
List<DayDecorator> decorators = new ArrayList<>();
decorators.add(new Markierung());
calendarView.setDecorators(decorators);
calendarView.refreshCalendar(currentCalendar);
//class Markierung
private class Markierung implements DayDecorator {
EditText huablauf=(EditText)getActivity().findViewById(R.id.huablauf);
@Override
public void decorate(DayView dayView) {
// I know I have to get my String to a date and then get it to
// dayView.getDate()! But my code didn´t work
dayView.getDate();
int color = Color.parseColor("#f9acb8");
dayView.setBackgroundColor(color);
}
//EditText我想获取日期
huablauf=(EditText)getActivity().findViewById(R.id.huablauf);
//添加日历日装饰器
List decorators=new ArrayList();
decorators.add(newmarkierung());
setDecorators(decorators);
calendarView.refreshCalendar(当前日历);
//类Markierung
私有类Markierung实现DayDecorator{
EditText huablauf=(EditText)getActivity().findViewById(R.id.huablauf);
@凌驾
公共空间装饰(DayView DayView){
//我知道我必须让我的字符串到一个日期,然后让它到
//dayView.getDate()!但我的代码不起作用
getDate();
int color=color.parseColor(#f9acb8”);
dayView.setBackgroundColor(颜色);
}
希望你能理解我的问题,任何人都能帮助:)
巴伐利亚的Thx试一试:
@Override
public void decorate(DayView dayView) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy",Locale.getDefault());
try{
if(dayView.getDate().equals(dateFormat.parse(huablauf.getText().toString()))){
int color = Color.parseColor("#f9acb8");
dayView.setBackgroundColor(color);
}
} catch (Exception e){
//Handle exception.
}
试试这个:
@Override
public void decorate(DayView dayView) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy",Locale.getDefault());
try{
if(dayView.getDate().equals(dateFormat.parse(huablauf.getText().toString()))){
int color = Color.parseColor("#f9acb8");
dayView.setBackgroundColor(color);
}
} catch (Exception e){
//Handle exception.
}
您使用listview添加日历视图了吗?更改为material calander View了吗?您使用listview添加日历视图了吗?更改为material calander View了我刚才正在讨论与Daydecontor相关的问题。我刚刚意识到这个问题太老了。可能太老了。:/该死,它不太老了…:(我把这一天看作是xD年,我只是在讨论有关Daydecotor的问题。我才意识到这个问题太老了。可能太老了。:/该死,它不太老了……:(我把这一天看作xD年。)