【发布时间】:2021-07-30 07:54:59
【问题描述】:
在我的项目中,我想检索索引处自定义属性的颜色值。就像在 android 中一样,我们有 TypedArray 来执行此功能。
final TypedArray typedArray = mContext.obtainStyledAttributes(attrs, R.styleable.CustomCalendarView, 0, 0);
calendarBackgroundColor = typedArray.getColor(R.styleable.CustomCalendarView_calendarBackgroundColor, getResources().getColor(R.color.white));
calendarTitleBackgroundColor = typedArray.getColor(R.styleable.CustomCalendarView_titleLayoutBackgroundColor, getResources().getColor(R.color.white));
calendarTitleTextColor = typedArray.getColor(R.styleable.CustomCalendarView_calendarTitleTextColor, getResources().getColor(R.color.black));
weekLayoutBackgroundColor = typedArray.getColor(R.styleable.CustomCalendarView_weekLayoutBackgroundColor, getResources().getColor(R.color.white));
typedArray.recycle();
所以我们在 Harmony 操作系统中没有 TypedArray。执行此功能的方式是什么?
【问题讨论】:
标签: java android huawei-mobile-services huawei-developers harmonyos