小编Saj*_*sbi的帖子

用字符串中的波斯数字替换英文数字,​​URL除外

我为波斯语字符串编写了一个自定义TextView,这个TextView应该将英文数字替换成波斯数字

public class PersianTextView extends TextView {

    public PersianTextView(Context context) {
        super(context);
    }

    public PersianTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public PersianTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void setText(CharSequence text, BufferType type) {
        String t = text.toString();
        t = t.replaceAll("0", "?");
        t = t.replaceAll("1", "?");
        t = t.replaceAll("2", "?");
        t = t.replaceAll("3", "?");
        t = t.replaceAll("4", "?");
        t = t.replaceAll("5", "?");
        t = t.replaceAll("6", "?");
        t = t.replaceAll("7", "?");
        t = …
Run Code Online (Sandbox Code Playgroud)

java string android textview

5
推荐指数
1
解决办法
757
查看次数

标签 统计

android ×1

java ×1

string ×1

textview ×1