我在Android消息传递应用程序中有一个textview,我收到了我的android手机的消息,并在textviews中显示了它们,如果文本是波斯语,我想将layout_gravity设置为正确,那么如何检测从uri以下获得的文本语言?

Uri uri = Uri.parse("content://sms/");

解决方法:

有Bidi个班级.此类具有getBaseLevel()方法,如果您的文本从左到右,则返回0,否则返回1(如果从右到左).

例:

@Override

public View getView(final int position, View convertView, ViewGroup parent) {

ViewHolder holder;

Bidi bidi = new Bidi(userList.get(position).getName(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);

if(bidi.getBaseLevel() == 0)

convertView = myInflater.inflate(R.layout.list_add_friends_row, null);

else

convertView = myInflater.inflate(R.layout.list_add_friends_row_mirror, null);

还有另一种方法baseIsLeftToRight(),可能最好在if语句中使用.结果与上述相同.

Bidi bidi = new Bidi(userList.get(position).getName(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);

if(bidi.baseIsLeftToRight())

convertView = myInflater.inflate(R.layout.list_add_friends_row, null);

else

convertView = myInflater.inflate(R.layout.list_add_friends_row_mirror, null);

public final class Bidi

extends Object

This class implements the Unicode Bidirectional Algorithm.

A Bidi object provides information on the bidirectional reordering of

the text used to create it. This is required, for example, to properly

display Arabic or Hebrew text. These languages are inherently mixed

directional, as they order numbers from left-to-right while ordering

most other text from right-to-left.

Once created, a Bidi object can be queried to see if the text it

represents is all left-to-right or all right-to-left. Such objects are

very lightweight and this text is relatively easy to process.

If there are multiple runs of text, information about the runs can be

accessed by indexing to get the start, limit, and level of a run. The

level represents both the direction and the ‘nesting level’ of a

directional run. Odd levels are right-to-left, while even levels are

left-to-right. So for example level 0 represents left-to-right text,

while level 1 represents right-to-left text, and level 2 represents

left-to-right text embedded in a right-to-left run.

标签:persian,sms,detection,android

来源: https://codeday.me/bug/20191119/2037955.html

android获得textview数值,android-如何获取textview中的文本语言?相关推荐

  1. 6 获取数组中最小值_C语言每日一练8——数组中最大值和最小值

    题目: 利用指针函数,求某数组中的最大值和最小值. 实现代码: /* ================================================================= ...

  2. 【CAD】通过VBA获取CAD中的文本

    同事需求,要提取单线图中的所有焊口编号和检测报告中的做比对.网上找了个有些麻烦,不能选取非文本,否则报错.于是修改代码如下. 用法: 1.打开cad文件 2.在VB编辑器中复制以下代码,然后运行 3. ...

  3. python用正则获取字幕中的文本

    首先去字幕库或字幕网站得到字幕文件,格式一般为srt.ass.Webvtt.STL等,将格式修改为后缀txt文件,可以在python中读取. 打开字幕观察它的格式,一般为序号,时间线,字幕文本,回车. ...

  4. js设置和获取html和文本,JS---DOM---设置和获取---标签内容和文本内容

    设置和获取---标签内容和文本内容 总结---设置: 使用innerText主要是设置文本的, 设置标签内容, 是没有标签的效果的 innerHTML是可以设置文本内容 innerHTML主要的作用是 ...

  5. java:获取后缀为doc、docx、xls、xlsx、ppt、pptx、pdf、xml的文件中的文本

    目录 pom 代码 结果 pom <dependency><groupId>org.apache.poi</groupId><artifactId>po ...

  6. android 获取textview的高度,Android TextView 高度问题

    参考:https://www.cnblogs.com/tc310/p/12721754.html 前言: 在我们做界面开发的时候,UI的标注图中经常是标注了文字的字号和文件的间距.而当我们使用多个Te ...

  7. android 获取布局textview,android – 获取TextView中文本的位置

    看看几个Paint方法: getTextBounds()和 measureText.我们可以使用它们来确定TextView中文本的偏移量.确定TextView中的偏移后,我们可以将其添加到TextVi ...

  8. android 应用之listview添加radiobutton,获取textView

    程序效果: 点击一整行,更换radiobutton选择. xml代码: [java] view plaincopy <?xml version="1.0" encoding= ...

  9. android textview坐标,android – 获取TextView中文本的位置

    看看几个Paint方法: getTextBounds()和 measureText.我们可以使用它们来确定TextView中文本的偏移量.确定TextView中的偏移后,我们可以将其添加到TextVi ...

最新文章

  1. AI推理与Compiler
  2. ubuntu15.10避免图形界面无法登录的jdk配置
  3. JDBC对MySQL数据库存储过程的调用
  4. 注解_自定义注解_元注解
  5. 技术揭秘之详解回收站删除文件恢复
  6. 显示/隐藏Mac系统中所有的隐藏文件
  7. 栈溢出(Stack Overflow)
  8. VB代码VB小程序:实现USB摄像头视频图像的监控、截图、录像
  9. 自然语言处理,计算机与人类“谈心”的关键
  10. ubuntu 安装caj阅读器
  11. NOT NULL 和 DEFAULT 的区别
  12. Aruba无线AP入坑心得
  13. C++ 字元陣列(C-style)、字元指標、String類別 使用方式整理
  14. 【学习记录贴16】cesium进行三维发布
  15. 什么蓝牙耳机颜值高?盘点四款高颜值蓝牙耳机
  16. python做表格教程_表格函数教程
  17. 图表色彩运用原理的全面解析
  18. 原生js获取document_常见的原生javascript DOM操作
  19. 安卓7.0以后如何开启手电筒
  20. 产业新闻-2006.06.02-05

热门文章

  1. 【Javascript】深入理解this作用域问题以及new/let/var/const对this作用域的影响
  2. 利用Arena Allocation避免HBase触发Full GC
  3. SLB+Tomcat时request.RemoteAddr无法获取正确的客户端IP的问题解决方案
  4. Codeforces Round #350 (Div. 2) B. Game of Robots 水题
  5. Exchange系列之exchange2003sp2部署
  6. python typing typescript_typescript
  7. ip68级防水可以泡多久_ip68级防水手机有哪些
  8. 农行运营合规管理心得体会_“乘风破浪”的农行合规达人秀来啦
  9. Python元组的操作
  10. javamelody监控java项目_使用javamelody监控javaEE