我有一个小应用程序,它使用自定义的LinearLayout,称为LinearlayoutOutlined.我想在其中绘制不同大小和彩色的盒子.它还有两个指示时间间隔的文本标签.在进行一些用户操作后,必须重新绘制布局.因此我按原样刷新布局
slotPanel.setDayBoundariesInMinutes( db, dw );
TimeSlot[] tSlots = nextDaysSlots.getGaps( dayOfWeek );
slotPanel.setItems( tSlots );
slotPanel.invalidate();
其中slotpanel是LinearLayoutOutlined实例.
我检测到onDraw方法被不断调用.在特定的循环次数之后,它不会停止调用.
这是整个LinearLayoutOutlined类:
包com.widgets;
public class LinearLayoutOutlined extends LinearLayout {
private int workingTimeBeginsInMinutes;
private int workingTimeFinishesInMinutes;
private TimeSlot[] items;
private Rect outline;
private Paint strokePaint = new Paint();
SimpleDateFormat formatter;
public LinearLayoutOutlined( Context context ) {
super( context );
setWillNotDraw( false );
}
public Linear