第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 HTML 標(biāo)記為 strings.xml 文件中的字符串著色?

如何使用 HTML 標(biāo)記為 strings.xml 文件中的字符串著色?

江戶川亂折騰 2023-02-16 16:28:44
我正在創(chuàng)建一個類似于 PokéDex 的應(yīng)用程序。我正在使用 RecyclerViewer 和 Mike Penz 的 FastItemAdapter。我的 Pokemon 類中有各種變量,其中兩個我遇到的問題是 String type 和 String weakness。我的目標(biāo)是在 strings.xml 文件中使用 HTML 標(biāo)記來添加字體顏色。在我的 ModelGenerator 類中,我有整個 Pokemon 列表,我從 strings.xml 文件中調(diào)用了相應(yīng)的字符串。口袋妖怪(我沒有展示 getter 和 setter)package com.example.pokedex;import android.os.Parcel;import android.os.Parcelable;import androidx.annotation.DrawableRes;public class Pokemon implements Parcelable {    private final int id;    private final String name;    private final String type;    private final String weakness;    private final int drawableResource;    private final String description;    private final String category;    private final String ability;    private final String abilityDescription;    private final String stats;    private final String height;    private final String weight;    private final String gender;    private Pokemon evolution;    public Pokemon(int id, String name, String type, String weakness, @DrawableRes int drawableResource,                   String description, String category, String ability, String abilityDescription,                   String stats, String height, String weight, String gender) {        this.id=id;        this.name = name;        this.type = type;        this.weakness = weakness;        this.drawableResource = drawableResource;        this.description = description;        this.category = category;        this.ability = ability;        this.abilityDescription = abilityDescription;        this.stats = stats;        this.height = height;        this.weight = weight;        this.gender = gender;    }    }    }
查看完整描述

1 回答

?
繁花不似錦

TA貢獻1851條經(jīng)驗 獲得超4個贊

您實際上可以將 HTML 部分包裝在 CDATA 部分中,例如

<string name="grass_poison"><![CDATA[<font color='#53E204'>Grass</font>]]>\u0020<![CDATA[<font color='#EB09FC'>Poison</font>]]></string>

在設(shè)置文本使用時,

Html.fromHtml(context.getString(R.string.grass_poison));


查看完整回答
反對 回復(fù) 2023-02-16
  • 1 回答
  • 0 關(guān)注
  • 124 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號