imageAnimator->SetPosition(left, top);
imageAnimator->Resize(width, height);
imageAnimator->SetViewId(viewId);
- imageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ // imageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
imageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
ImageAnimatorInfo *imageAnimatorInfo = new ImageAnimatorInfo[numFrames];
imageAnimator->SetImageAnimatorSrc(imageAnimatorInfo, numFrames, time); // 200 is the default delay time
imageAnimator->SetTimeOfPause(time);
- imageAnimator->SetRepeatTimes(1);
- imageAnimator->SetReverse(true);
- // imageAnimator->SetVisible(true);
+ imageAnimator->SetRepeat(true);
+ // imageAnimator->SetReverse(true);
+ // imageAnimator->SetVisible(true);
}
/*带默认参数的初始化label*/
void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, const char *viewId, const char *text, int fontSize, const char *fontName)
}
/*替换字符串中的变量*/
- void UpdateLabelText(UILabelExt *&label, const std::string &newText)
+ std::string UpdateLabelText(UILabelExt *&label, const std::string &newText, UIResourceTextId id)
{
if (label == nullptr)
{
- return;
+ return nullptr;
}
+ /*取Id对应的字符串*/
+ UILabelExt *labelext = new UILabelExt();
+ labelext->SetTextId(id);
+ std::string text = labelext->GetText();
- std::string str = label->GetText();
- printf("UpdateLabel:%s->%s\r\n", str.c_str(), newText.c_str());
+ printf("UpdateLabel:%s->%s\r\n", text.c_str(), newText.c_str());
// 找到标志"XX"在字符串中的位置
- size_t pos = str.find("XX");
+ size_t pos = text.find("XX");
if (pos != std::string::npos)
{
// 替换标志"XX"为更新字符串
- str.replace(pos, 2, newText); // 2 是标志"XX"的长度
- label->SetText(str.c_str());
+ text.replace(pos, 2, newText); // 2 是标志"XX"的长度
+ printf("newText:%s\r\n", text.c_str());
+ label->SetText(text.c_str());
+ }
+ else
+ {
+ printf("找不到变量标志位XX,请注意是否已经被修改!\r\n");
}
+
+ delete labelext;
+ return text;
}
/*更新数字*/
- void UpdateLabel(UILabelExt *&label, int num)
+ std::string UpdateLabel(UILabelExt *&label, int num, UIResourceTextId id)
{
+ if (label == nullptr)
{
- return;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label is error");
+ return nullptr;
}
- UpdateLabelText(label, std::to_string(num));
+ std::string str = UpdateLabelText(label, std::to_string(num), id);
+ return str;
}
/*更新文本*/
- void UpdateLabel(UILabelExt *&label, const std::string &updateStr)
+ std::string UpdateLabel(UILabelExt *&label, const std::string &updateStr, UIResourceTextId id)
{
if (label == nullptr)
{
- return;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label is error");
+ return nullptr;
}
- UpdateLabelText(label, updateStr);
+ std::string str = UpdateLabelText(label, updateStr, id);
+ return str;
}
/*设置label的Id*/
}
-/*更新label的字符串*/
void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, const char *viewId, const char *text, int fontSize = 30, const char *fontName = DEFAULT_VECTOR_FONT_FILENAME);
/*通用替换*/
- void UpdateLabelText(UILabelExt *&label, const std::string &newText);
+ std::string UpdateLabelText(UILabelExt *&label, const std::string &newText, UIResourceTextId id);
/*更新label的数字*/
- void UpdateLabel(UILabelExt *&label, int num);
+ std::string UpdateLabel(UILabelExt *&label, int num, UIResourceTextId id);
/*更新label的字符串*/
- void UpdateLabel(UILabelExt *&label, const std::string &updatestr);
+ std::string UpdateLabel(UILabelExt *&label, const std::string &updatestr, UIResourceTextId id);
/*通过labelext获取Id设置label*/
void SetLabelId(UILabel *&label, UIResourceTextId id);
}