改变网格的单元的彩色 [英] Change Color of cell of grid

查看:104
本文介绍了改变网格的单元的彩色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变使用的格栅位置的数目的网格单元的颜色。例如我有5X6格指30 gridItems,所以我想改变21位的颜色。请告诉我,我怎么能做到这一点没有点击网格视图。

I want to change the color of the grid cell using the number of grid position . e.g. I have 5X6 grid means 30 gridItems so i want to change the color of 21st position. Please tell me how can i do this Without clicking on the Grid View.

推荐答案

您需要定义这个自定义适配器。
在适配器的 getView()方法,你必须检查位置参数是否等于用21。如果它等于21,然后更改背景当前单元格。

You will need to define a custom adapter for this.
In the getView() method of adapter you'll have to check the position parameter if is equal with 21. If it's equal with 21, then change the background for currently cell.

如果你没有必须定义一个定制适配器还经历,那么它会更有意义,通过一个例子第一。
下面是一个使用一个定制适配器以显示图像一个GridView的一个例子。

If you did not had the experience to define a custom adapter yet, then it will make more sense to pass through an example first.
Here's an example of a GridView that uses a custom adapter to display images.

这篇关于改变网格的单元的彩色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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