uCGUI listview 添加数据行问题
时间:10-02
整理:3721RD
点击:
以下是我的代码:
void UpdateListView(void)
{
unsigned char i;
unsigned char str_date[10];
unsigned char str_time[10];
unsigned char str_num[10];
char Record[3][10];
/********* date translate to string type (example : 2014-06-06) **************/
str_date[0] = Clock.Year/1000+0x30; //year first bit
str_date[1] = (Clock.Year/100)%10+0x30; //year second bit
str_date[2] = (Clock.Year%100)/10+0x30; //year third bit
str_date[3] = Clock.Year%10+0x30; //year fouth bit
str_date[4] = '-';
str_date[5] = Clock.Month/10+0x30; //month first bit
str_date[6] = Clock.Month%10+0x30; //month second bit
str_date[7] = '-';
str_date[8] = Clock.Day/10+0x30; //day fisrt bit
str_date[9] = Clock.Day%10+0x30; //day second bit
/*********** time translte to string type (example: 12:12:00) **************/
str_time[0] = Clock.Hour/10+0x30; //hour fisrt bit
str_time[1] = Clock.Hour%10+0x30; //hour second bit
str_time[2] = '-';
str_time[3] = Clock.Min/10+0x30; //minute 1 bit
str_time[4] = Clock.Min%10+0x30; //minute 2 bit
str_time[5] = '-';
str_time[6] = Clock.Sec/10+0x30; //second 1 bit
str_time[7] = Clock.Sec%10+0x30; //second 2 bit
/*********** number of student or teacher translate to string ***************/
str_num[0] = card_num;
for(i=0;i<10;i++)
{
Record[0] = str_date;
Record[1] = str_time;
Record[2] = str_num;
}
/************* translate to Record to display in listview *******************/
for (i = 0; i < GUI_COUNTOF(Record); i++)
{
LISTVIEW_AddRow(listview, ( GUI_ConstString *)Record);
}
}
我创建了一个LISTVIEW 这个函数是用于当检测到数据是添加一行,但是这最基本的都不行:
原型:void LISTVIEW_AddRow(LISTVIEW_Handle hObj, const GUI_ConstString * ppText);
原型:void LISTVIEW_SetItemText(LISTVIEW_Handle hObj, unsigned Column,unsigned Row, const char * s);
这两个添加 数据的函数都是 const 类型,而且我使用变量 作为数据添加到行时,就进入硬件错误,不知道怎么回事?有没有好的建议,和例程呢,谢谢!
我没用过LISTVIEW,但是你的程序存在下面的问题,不知道是不是此原因引起的,你自己修改后试一下吧:
for(i=0;i<10;i++)
{
Record[0] = str_date;
Record[1] = str_time;
Record[2] = str_num;
}
这个循环里面,i 没有起到任何作用, Record[x] = str_xxxx的实质是
const ((char *)(Record[x])) = (unsigned char *)str_xxxx;
即将指向str_xxxx的指针赋值给指针常数Record[x],数据类型不匹配;
如果编译能够通过,这个程序也存在不确定的问题;