安卓:触发颜色改变后重绘 [英] Android: Trigger redraw after a colour change

查看:181
本文介绍了安卓:触发颜色改变后重绘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前工作的一个连接四种游戏。

I am currently working on a Connect four game.

我的游戏作品深受用户pressing新游戏按钮。这就得出42(7 * 6)绿色圆圈筛选。这些圆圈是用来重新在连接四局present孔即绿色圆圈目前不包含一个球员的令牌/计数器

My game works by the user pressing the 'New game' button. This then draws 42 (7*6) green circles to screen. These circles are used to represent holes on the connect four board i.e. green circles currently do not contain a player's token/counter

在这个时刻,我就加入令牌/计数器工作。我有code工作(到某一点),使用户可以选择一个列。使用log.d()看来,我成功改变差距的颜色值。我的问题是,我不知道如何发送彩色这个不断变化的视图,即这样的差距实际上从绿色变为红色(玩家的令牌颜色)。

At this moment in time I am working on adding the tokens/counters. I have got code working (to a certain point) that enables the user to pick a column. Using log.d() It seems that I am successful changing the colour value of the gaps. My problem is that I do not know how to send this changing in colour to the View i.e. so the gap actually changes from green to red (player's token colour).

我如何发送到View等的差距重新拉的请求?

How can I send a request to the View so the gap is re-drawn?

N.B。对不起,缺乏code,但它是目前混乱和不充分的工作。
视图是由ConnectFourView.java(视图)控制,游戏画面Board.java(型号)和code可以算出这列已经被选定Gaps.java(控制器)

N.B. Sorry for the lack of code but it is currently messy and not fully working. The View is controlled by a ConnectFourView.java (View), the game screen is Board.java (Model) and the code that works out which column has been selected Gaps.java (controller)

推荐答案

就叫无效()你的看法,这将重绘

Just call invalidate() on your view and it will be redrawn

这篇关于安卓:触发颜色改变后重绘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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