eclipse 在日历视图中更改一天的颜色,android
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15874175/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing color of single day in calendarview, android
提问by Werdli
I've got the calendarview in eclipse and now I'm trying to change the appearance of a single day to highlight dates. I didn't find any useful method here, only changes of appearances of whole weekdates or monthdates. So is there a possibility to highlight a single day?
我在 eclipse 中有日历视图,现在我试图改变一天的外观以突出显示日期。我在这里没有找到任何有用的方法,只有整个星期或月份的外观变化。那么是否有可能突出显示某一天?
Also i know there are like 3 posts with the same issue, but none of them got answered.
我也知道有 3 个帖子有同样的问题,但没有一个得到回答。
采纳答案by Abhishek Sabbarwal
回答by Stav Bodik
You may do it by obtain the child views of the CalendarView
and change there configuations:
您可以通过获取子视图CalendarView
并更改那里的配置来实现:
final CalendarView calendar = new CalendarView(this);
java.lang.reflect.Field field = null;
Class<?> cvClass = calendar.getClass();
try {
field = cvClass.getDeclaredField("mDayNamesHeader");
field.setAccessible(true);
} catch (NoSuchFieldException e) {
}
ViewGroup tv = null;
try {
tv = (ViewGroup) field.get(calendar);
} catch (IllegalAccessException e) {}
catch (IllegalArgumentException ){}
TextView k = (TextView) tv.getChildAt(1);
k.setTextColor(Color.RED);
Here You can find all declarations:
在这里您可以找到所有声明: