如何在 Android 上的 TextView 上显示阿拉伯语文本

作者&投稿:蒲罗 (若有异议请与网页底部的电邮联系)
android中如何在TextView中显示文字的同时加上笑脸一样的图标~

使用 SpannableString 这个类,可以防止图片和添加文本,然后放置在textView中就可以了

TextView是最常用的组件之一用于显示文本
像这种需求通常是两个TextView组成的解决方案
用两个TextView 一个作为标题,一个作为动态内容
还是用一个TexeView 直接getText().toString() 得到文本再调用String的api split(":") 拆分,即通过:进行拆分
通常在android中都是用两个TextVew来处理的,前面一个TextVew作为标题,是固定不变的,后面一个TextVew作为变量,动态显示内容

获取textView文本的api :
String txt = textView.getText().toString();

import android.content.Context;
import android.graphics.Typeface;
public final class Farsi {
public static boolean isFarsiConversionNeeded = true;
private final static String szLamAndAlef = Character
.toString((char) 0xfedf)
+ Character.toString((char) 0xfe8e); // Lam + Alef
private final static String szLamStickAndAlef = Character
.toString((char) 0xfee0)
+ Character.toString((char) 0xfe8e); // Lam (Sticky !!!)+
// Alef
private final static String szLa = Character.toString((char) 0xfefb); // La
private final static String szLaStick = Character.toString((char) 0xfefc); // La
// (Sticky!!!)
private final static String szLamAndAlefWoosim = Character
.toString((char) 0xe1)
+ Character.toString((char) 0xbb); // Lam + Alef

private final static String szLamStickAndAlefWoosim = Character
.toString((char) 0x90)
+ Character.toString((char) 0xbb); // Lam (Sticky !!!)+
// Alef

private final static String szLaWoosim = Character.toString((char) 0xd9); // La
private final static String szLaStickWoosim = Character
.toString((char) 0xd9); // La

// (Sticky!!!)

private static final class struc {
public char character;
public char endGlyph;
public char iniGlyph;
public char midGlyph;
public char isoGlyph;

public struc(char Character, char EndGlyph, char IniGlyph,
char MidGlyph, char IsoGlyph) {
character = Character;
endGlyph = EndGlyph;
iniGlyph = IniGlyph;
midGlyph = MidGlyph;
isoGlyph = IsoGlyph;
}
}

static struc[] arrStruc = {
new struc((char) 0x630, (char) 0xfeac, (char) 0xfeab,
(char) 0xfeac, (char) 0xfeab),
new struc((char) 0x62f, (char) 0xfeaa, (char) 0xfea9,
(char) 0xfeaa, (char) 0xfea9),
new struc((char) 0x62c, (char) 0xfe9e, (char) 0xfe9f,
(char) 0xfea0, (char) 0xfe9d),
new struc((char) 0x62d, (char) 0xfea2, (char) 0xfea3,
(char) 0xfea4, (char) 0xfea1),
new struc((char) 0x62e, (char) 0xfea6, (char) 0xfea7,
(char) 0xfea8, (char) 0xfea5),
new struc((char) 0x647, (char) 0xfeea, (char) 0xfeeb,
(char) 0xfeec, (char) 0xfee9),
new struc((char) 0x639, (char) 0xfeca, (char) 0xfecb,
(char) 0xfecc, (char) 0xfec9),
new struc((char) 0x63a, (char) 0xfece, (char) 0xfecf,
(char) 0xfed0, (char) 0xfecd),
new struc((char) 0x641, (char) 0xfed2, (char) 0xfed3,
(char) 0xfed4, (char) 0xfed1),
new struc((char) 0x642, (char) 0xfed6, (char) 0xfed7,
(char) 0xfed8, (char) 0xfed5),
new struc((char) 0x62b, (char) 0xfe9a, (char) 0xfe9b,
(char) 0xfe9c, (char) 0xfe99),
new struc((char) 0x635, (char) 0xfeba, (char) 0xfebb,
(char) 0xfebc, (char) 0xfeb9),
new struc((char) 0x636, (char) 0xfebe, (char) 0xfebf,
(char) 0xfec0, (char) 0xfebd),
new struc((char) 0x637, (char) 0xfeTypeface tf = Farsi.GetFarsiFont(this);
MyTextView.setTypeface(tf);
MyTextView.setText(Farsi.Convert("سلام"));
, (char) 0xfeMyTextView.setText(Farsi.Convert("سلام"));
,
(char) 0xfec4, (char) 0xfec1),
new struc((char) 0x643, (char) 0xfeda, (char) 0xfedb,
(char) 0xfedc, (char) 0xfed9),
new struc((char) 0x645, (char) 0xfee2, (char) 0xfee3,
(char) 0xfee4, (char) 0xfee1),
new struc((char) 0x646, (char) 0xfee6, (char) 0xfee7,
(char) 0xfee8, (char) 0xfee5),
new struc((char) 0x62a, (char) 0xfe96, (char) 0xfe97,
(char) 0xfe98, (char) 0xfe95),
new struc((char) 0x627, (char) 0xfe8e, (char) 0xfe8d,
(char) 0xfe8e, (char) 0xfe8d),
new struc((char) 0x644, (char) 0xfede, (char) 0xfedf,
(char) 0xfee0, (char) 0xfedd),
new struc((char) 0x628, (char) 0xfe90, (char) 0xfe91,
(char) 0xfe92, (char) 0xfe8f),
new struc((char) 0x64a, (char) 0xfef2, (char) 0xfef3,
(char) 0xfef4, (char) 0xfef1),
new struc((char) 0x633, (char) 0xfeb2, (char) 0xfeb3,
(char) 0xfeb4, (char) 0xfeb1),
new struc((char) 0x634, (char) 0xfeb6, (char) 0xfeb7,
(char) 0xfeb8, (char) 0xfeb5),
new struc((char) 0x638, (char) 0xfec6, (char) 0xfec7,
(char) 0xfec8, (char) 0xfec5),
new struc((char) 0x632, (char) 0xfeb0, (char) 0xfeaf,
(char) 0xfeb0, (char) 0xfeaf),
new struc((char) 0x648, (char) 0xfeee, (char) 0xfeed,
(char) 0xfeee, (char) 0xfeed),
new struc((char) 0x629, (char) 0xfe94, (char) 0xfe93,
(char) 0xfe93, (char) 0xfe93),
new struc((char) 0x649, (char) 0xfef0, (char) 0xfeef,
(char) 0xfef0, (char) 0xfeef),
new struc((char) 0x631, (char) 0xfeae, (char) 0xfead,
(char) 0xfeae, (char) 0xfead),
new struc((char) 0x624, (char) 0xfe86, (char) 0xfe85,
(char) 0xfe86, (char) 0xfe85),
new struc((char) 0x621, (char) 0xfe80, (char) 0xfe80,
(char) 0xfe80, (char) 0xfe80),
new struc((char) 0x626, (char) 0xfe8a, (char) 0xfe8b,
(char) 0xfe8c, (char) 0xfe89),
new struc((char) 0x623, (char) 0xfe84, (char) 0xfe83,
(char) 0xfe84, (char) 0xfe83),
new struc((char) 0x622, (char) 0xfe82, (char) 0xfe81,
(char) 0xfe82, (char) 0xfe81),
new struc((char) 0x625, (char) 0xfe88, (char) 0xfe87,
(char) 0xfe88, (char) 0xfe87),
new struc((char) 0x67e, (char) 0xfb57, (char) 0xfb58,
(char) 0xfb59, (char) 0xfb56), // peh
new struc((char) 0x686, (char) 0xfb7b, (char) 0xfb7c,
(char) 0xfb7d, (char) 0xfb7a), // cheh
new struc((char) 0x698, (char) 0xfb8b, (char) 0xfb8a,
(char) 0xfb8b, (char) 0xfb8a), // jeh
new struc((char) 0x6a9, (char) 0xfb8f, (char) 0xfb90,
(char) 0xfb91, (char) 0xfb8e), // keheh
new struc((char) 0x6af, (char) 0xfb93, (char) 0xfb94,
(char) 0xfb95, (char) 0xfb92), // gaf
// new struc((char) 0x6cc, (char) 0xfbfd, (char) 0xfbfe,
// (char) 0xfbff, (char) 0xfbfc), // Farsi yeh
new struc((char) 0x6cc, (char) 0xfbfd, (char) 0xfef3,
(char) 0xfef4, (char) 0xfbfc), // Arabic yeh
new struc((char) 0x6c0, (char) 0xfba5, (char) 0xfba4,
(char) 0xfba5, (char) 0xfba4) // heh with yeh
};

您可以使用波斯语类来执行此操作。
import android.content.Context;
import android.graphics.Typeface;

public final class Farsi {

public static boolean isFarsiConversionNeeded = true;

private final static String szLamAndAlef = Character
.toString((char) 0xfedf)
+ Character.toString((char) 0xfe8e); // Lam + Alef

private final static String szLamStickAndAlef = Character
.toString((char) 0xfee0)
+ Character.toString((char) 0xfe8e); // Lam (Sticky !!!)+
// Alef


浦城县15919272485: Android 5.0 SEAndroid下怎么获得对一个内核节点的访问权限 -
众戴槐杞: 第一步:找到需要访问该内核节点的进程(process),这个节点由system_server进程来访问第二步:打开文件AndroidL/android/external/sepolicy/file_contexts.be仿照这个文件里的写法,为这个定义一个你想要的名字:/dev/tegra.* u:object_r...

浦城县15919272485: android 怎么在te里面添加service权限 -
众戴槐杞: 先root,在下载个RE文件管理器,找到你要添加的文件,re管理器添加就好了

浦城县15919272485: 如何让Android系统或Android应用执行shell脚本 -
众戴槐杞: 一、Android应用启动服务执行脚本1 如何写服务和脚本 在android源码根目录下有/device/tegatech/tegav2/init.rc文件相信大家对这个文件都不陌生(如果不明白就仔细研读下android启动流程).如果在该脚本文件中添加诸如以下服务:service ...

浦城县15919272485: 如何在eclipse中添加android adt -
众戴槐杞: 在eclipse中添加android adt方法:1)打开Eclipse ,选择 Help > Install New Software.....2)点击对话窗口中的”Add”.3)点OK确认后,选择Work with列表中的adt16.01,列表中会显示Pending…加载中.4)等到一段时间后,会出现...

浦城县15919272485: 如何在Android Studio中创建File Templates -
众戴槐杞: 1、打开androidstudio右击res文件夹2、鼠标移动到New—>AndroidResourceFile3、单击ResourceType三角下拉框4、选择Animator,然后输入文件名即可.5、clean一下工程文件.

浦城县15919272485: 如何在eclipse中添加android ADT
众戴槐杞: 将adt导入eclipse方法步骤 第一步,添加ADT. 打开eclipse,进入工作界面后点击菜单栏的help,选择install new software.进入后点击添加(add)按钮.下载的文件一定是压缩文件. 第二步,加载ADT. 选择Add后,输入要输入的名字和地址...

浦城县15919272485: 如何在Android应用中使用已有的SQLite数据库 -
众戴槐杞: 其主要思路是:1. 把数据库分解成几个asset文件.2. 当需要打开数据库时,如果数据库不存在,就把那几个asset文件重新合并成一个数据库文件.3. 如果数据库的版本改变了,就在onUpgrade()方法中把数据库文件删除掉.下面是代码://...

浦城县15919272485: android程序开发将sql数据库的一种数字信息累加显示在te?
众戴槐杞: 拿到收据之后在方法体里面计算然后return一个值然后set

浦城县15919272485: 如何在Android中使用 StrictMode? -
众戴槐杞: 深圳华清刘老师为您解答:第一步 启用strictmode 第2页:第一步 启用strictmode 为了能在应用中启用和配置StrictMode,开发者最好尽可能在应用程序的生命周期的早段使用,方法是调用StrictMode的方法setThreadPolicy.当使用常用监控类的...

浦城县15919272485: 如何在Android Studio上使用Github -
众戴槐杞: 打开Android studio的界面中之后,选中菜单中的“file”》》“settings”的选项,点击进入.进入到选项的设置界面中之后,project settings中可以点击为”Tasks“》》“Servers”的选项.在右边框中位置中,点击“+”,弹出的下拉的菜单...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网