使用希伯来语时,Android的计算器的TextView [英] Android textview stackoverflow when using Hebrew

查看:139
本文介绍了使用希伯来语时,Android的计算器的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

结果
我的应用程序从一个RESTful HTTP源检索数据。结果
有时,会出现Hewbrew文本。结果
标题קולהמדיה,עמודהבית结果
内容הפיג'מות - עונה6פרק12עכשיולצפייהישירה! קישור:הצגאתהדף


My app is retrieving data from a RESTful http source.
Sometimes, there will be Hewbrew text.
title קול המדיה, עמוד הבית
content הפיג'מות - עונה 6 פרק 12 עכשיו לצפייה ישירה! קישור: הצג את הדף

一切都很好,直到它有一个TextView使用。
我用我自己的列表适配器将出现以下情况时,本文试图得到加载:

Everything is fine until it has to be used in a textview. I'm using my own list adapter and the following happens when this text tries to get loaded:

I/dalvikvm( 2524): Stack overflow, expanding (0x41048200 to 0x41048000)
I/dalvikvm( 2524): Shrank stack (to 0x41048200, curFrame is 0x41049cd8)
D/AndroidRuntime( 2524): Shutting down VM
W/dalvikvm( 2524): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
E/AndroidRuntime( 2524): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 2524): java.lang.StackOverflowError
E/AndroidRuntime( 2524):        at android.text.Styled.drawText(Styled.java:290)

所以,我试图用一个try / catch围绕code,但我没有任何帮助。美中不足的不捕获该异常。

So, I tried to use a try/catch around the code, but I no help. The catch doesn't catch this exception.

我的code:

try{    
   holder.content.setText(currPage.GetContent())      
   holder.title.setText(currPage.GetTitle());      
} catch (StackOverflowError e){      
   e.printStackTrace();  
}

这不起作用,因为这不是在异常实际发生的事情。这是当文本被绘制到屏幕上。我不知道该如何阻止这种情况发生。
我真的宁愿只是有一个空白的领域,如果这是最简单的修复,但我不知道如何来检测希伯来文是体面的方式。
任何帮助和建议将是极大的AP preciated。

That doesn't work because that's not where the exception is actually happening. It's when the text is being drawn onto the screen. I don't know how to stop this from happening. I really would rather just have a blank field if that is the easiest fix, but I don't know how to detect for Hebrew text is decent way. Any help and suggestions would be greatly appreciated.

谢谢
干杯,
特里。

Thanks Cheers, Terry.

logcat的输出:

logcat output:

I/dalvikvm( 2411): Stack overflow, expanding (0x41048200 to 0x41048000)
I/dalvikvm( 2411): Shrank stack (to 0x41048200, curFrame is 0x41049cd8)
D/AndroidRuntime( 2411): Shutting down VM
W/dalvikvm( 2411): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
E/AndroidRuntime( 2411): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 2411): java.lang.StackOverflowError
E/AndroidRuntime( 2411):        at android.text.Styled.drawText(Styled.java:290)
E/AndroidRuntime( 2411):        at android.text.Layout.drawText(Layout.java:1366)
E/AndroidRuntime( 2411):        at android.text.Layout.draw(Layout.java:339)
E/AndroidRuntime( 2411):        at android.widget.TextView.onDraw(TextView.java:3921)
E/AndroidRuntime( 2411):        at android.view.View.draw(View.java:5838)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1486)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1484)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.View.draw(View.java:5841)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1486)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.View.draw(View.java:5841)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1486)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.widget.AbsListView.dispatchDraw(AbsListView.java:1319)
E/AndroidRuntime( 2411):        at android.widget.ListView.dispatchDraw(ListView.java:2820)
E/AndroidRuntime( 2411):        at android.view.View.draw(View.java:5944)
E/AndroidRuntime( 2411):        at android.widget.AbsListView.draw(AbsListView.java:2121)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1486)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1484)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.View.draw(View.java:5841)
E/AndroidRuntime( 2411):        at android.widget.FrameLayout.draw(FrameLayout.java:352)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1486)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1484)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1484)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1484)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1484)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.View.draw(View.java:5841)
E/AndroidRuntime( 2411):        at android.widget.FrameLayout.draw(FrameLayout.java:352)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1486)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.drawChild(ViewGroup.java:1484)
E/AndroidRuntime( 2411):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
E/AndroidRuntime( 2411):        at android.view.View.draw(View.java:5841)
E/AndroidRuntime( 2411):        at android.widget.FrameLayout.draw(FrameLayout.java:352)
E/AndroidRuntime( 2411):        at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1847)
E/AndroidRuntime( 2411):        at android.view.ViewRoot.draw(ViewRoot.java:1217)
E/AndroidRuntime( 2411):        at android.view.ViewRoot.performTraversals(ViewRoot.java:1030)
E/AndroidRuntime( 2411):        at android.view.ViewRoot.handleMessage(ViewRoot.java:1482)
E/AndroidRuntime( 2411):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2411):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 2411):        at android.app.ActivityThread.main(ActivityThread.java:3948)
E/AndroidRuntime( 2411):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2411):        at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 2411):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime( 2411):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
E/AndroidRuntime( 2411):        at dalvik.system.NativeStart.main(Native Method)

请注意:原帖和标题说阿拉伯语。它是正确的说希伯来语。也许它很重要。

NOTE: The original post and title said Arabic. It's been correct to say Hebrew. Maybe it matters.

推荐答案

我已经写阿拉伯文文本一个TextView很多次,没有看到一个堆栈溢出异常,这也是一个从右到左(RTL)语言。你修改的onDraw()方法或任何其他方法可能会造成这个错误?

I have written Arabic text to a TextView many times without seeing a stack overflow exception, which is also a Right-to-Left (RTL) language. Did you modify the onDraw() method or any other method that might be causing this error?

如果您无法找到原因,这应该返回真正如果给定的的inputText 包含希伯来字符:

If you can't find the reason, this should return true if the given inputText contains Hebrew characters:

Pattern.matches("(\\p{InHebrew})+", inputText);

您可能还希望如果其他语言可能会带来问题,以禁止任何非拉丁字符。本网站包含了所有你能匹配的UNI code脚本的列表:
结果正则表达式教程 - 统一code字符

You might also want to disallow any non-Latin characters if other languages cause problems as well. This site contains a list of all of the unicode scripts you can match against:
Regex Tutorial - Unicode Characters

这篇关于使用希伯来语时,Android的计算器的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆