Android的CalendarView在随机掉落周 [英] Android CalendarView Drops Weeks at Random

查看:228
本文介绍了Android的CalendarView在随机掉落周的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是标准的 CalendarView 在我的项目之一。当我在一个对话框中显示它,它似乎正常工作,但是当我在应用另一个活动显示它,似乎随意离开了几个星期。上下滚动通过日历使他们再次出现,但其他人消失。失踪一周往往是一个包括我将它设置为使用的setDate()所以没有选择的日期,甚至图所示。

日期

有其他人看到与 CalendarView 这种行为?我使用的SDK V17

 < CalendarView
        机器人:ID =@ + ID / cv_planner
        机器人:layout_width =match_parent
        机器人:layout_height =0dp
        机器人:layout_weight =1
        机器人:填充=@扪/ item_list_padding
        机器人:selectedDateVerticalBar =@彩色/水鸭
        机器人:selectedWeekBackgroundColor =@彩色/水鸭
        机器人:showWeekNumber =真/>


解决方案

作为临时的解决办法,强制刷新滚动下/上一两个月,然后滚动回来。你应该看到,刷新导致丢失一周出现。

只要这确实是一个错误,没有解决办法,参与来弥补这个code不会是微不足道的。我想像它会涉及张贴由含活性你的UI线程可运行的方法,它的渲染,检查是否有失踪一周后,将分析视图,然后迫使视图的刷新不知何故(这将是最简单进入前路子类的CalendarView本身,并试图在更细的粒度来控制它的渲染,通过onMeasure或onLayout)说。

更新:已找到一个解决办法 - <一个href=\"http://stackoverflow.com/questions/18534349/calendarview-issues-when-used-directly-outside-of-a-datepicker/18540911#18540911\">CalendarView使用时直接(外一个datepicker的)

问题

I'm using the standard CalendarView in one of my projects. When I display it in a dialog, it seems to work normally, but when I display it in another activity in the app, it seems to leave out a few weeks at random. Scrolling up and down through the calendar causes them to appear again, but others to disappear. Often the missing week is the one including the date that I set it to using setDate() so no selected date is even shown.

Has anyone else seen this behavior with CalendarView? I'm using SDK v17.

    <CalendarView
        android:id="@+id/cv_planner"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:padding="@dimen/item_list_padding"
        android:selectedDateVerticalBar="@color/teal"
        android:selectedWeekBackgroundColor="@color/teal"
        android:showWeekNumber="true" />

解决方案

As a temporary fix, force a refresh by scrolling down/up a month or two, and then scroll back. You should see that the refresh causes the missing week to appear.

Provided this is truly a bug with no workaround, the code involved to compensate for this wouldn't be trivial. I'd imagine it would involve posting a runnable method on your UI thread from the containing activity that would analyze the view after its rendered to check for a missing week, and then forcing a refresh of the view somehow (This would be "easiest" way before getting into sub-classing the CalendarView itself and trying to control its rendering at a finer granularity, say through onMeasure or onLayout).

Update: Found a workaround - CalendarView Issues when Used Directly (Outside of a DatePicker)

这篇关于Android的CalendarView在随机掉落周的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆