在EditText上Android应用程序崩溃时,长按文本 [英] Android app crashing when long click text in edittext

查看:439
本文介绍了在EditText上Android应用程序崩溃时,长按文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可编辑的文本的对话片段。当上的文字,你长的preSS它崩溃的应用程序。不知道为什么这突然开始发生,因为它曾经工作正常,但现在崩溃一致,并不太清楚在哪里看的logcat中似乎暗示它试图夸大了很久单击视图。

下面是简单的对话片断创建(MobileAlertDialog从DialogFragment继承了与设置一些默认)

  VAR alertDialog =新Widgets.MobileAlertDialogFragment();
            alertDialog.Title = s.Name;
            输入的EditText =新的EditText(本);
            (输入作为EditText上)。文本= s.Value;
            alertDialog.MessageView =输入;
            alertDialog.PositiveCallback =()=>
            {
              s.Value = input.Text;
              RefreshSettings();
            };
            alertDialog.CancelCallback =()=>
            {
              //没做什么...
            };
            alertDialog.Show(this.SupportFragmentManagerENTER_VALUE_DIALOG);

和这里的logcat的:

  ---------开始的/ dev /日志/主11月7日至20日:55:10.459 D / AndroidRuntime(4886):关闭VM11月7日至20日:55:10.459 W / dalvikvm(4886):主题ID = 1:螺纹未捕获的异常退出(组= 0x41fe8930)---------的/ dev /日志/系统开始11月7日至20日:55:10.467 E / AndroidRuntime(4886):致命异常:主要11月7日至20日:55:10.467 E / AndroidRuntime(4886):android.view.InflateException:二进制XML文件行#31:错误充气类<&不明GT;11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.LayoutInflater.createView(LayoutInflater.java:613)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.LayoutInflater.rInflate(LayoutInflater.java:746)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.LayoutInflater.inflate(LayoutInflater.java:489)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.LayoutInflater.inflate(LayoutInflater.java:396)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在com.android.internal.widget.ActionBarContextView.initForMode(ActionBarContextView.java:206)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在com.android.internal.policy.impl.PhoneWindow $ DecorView.startActionMode(PhoneWindow.java:2305)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2243)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.ViewGroup.startActionModeForChild(ViewGroup.java:623)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.ViewGroup.startActionModeForChild(ViewGroup.java:623)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.ViewGroup.startActionModeForChild(ViewGroup.java:623)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.ViewGroup.startActionModeForChild(ViewGroup.java:623)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.ViewGroup.startActionModeForChild(ViewGroup.java:623)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.View.startActionMode(View.java:4302)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.widget.Editor.startSelectionActionMode(Editor.java:1517)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.widget.Editor.performLongClick(Editor.java:839)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.widget.TextView.performLongClick(TextView.java:8066)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.View $ CheckForLong press.run(View.java:17351)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.os.Handler.handleCallback(Handler.java:725)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.os.Handler.dispatchMessage(Handler.java:92)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.os.Looper.loop(Looper.java:137)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.app.ActivityThread.main(ActivityThread.java:5041)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在java.lang.reflect.Method.invokeNative(本机方法)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在java.lang.reflect.Method.invoke(Method.java:511)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在dalvik.system.NativeStart.main(本机方法)11月7日至20日:55:10.467 E / AndroidRuntime(4886):因:java.lang.reflect.InvocationTargetException11月7日至20日:55:10.467 E / AndroidRuntime(4886):在java.lang.reflect.Constructor.constructNative(本机方法)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在java.lang.reflect.Constructor.newInstance(Constructor.java:417)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.view.LayoutInflater.createView(LayoutInflater.java:587)11月7日至20日:55:10.467 E / AndroidRuntime(4886):28 ...更多11月7日至20日:55:10.467 E / AndroidRuntime(4886):java.lang.ArrayIndexOutOfBoundsException:产生的原因长度= 24;指数= 223111月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.content.res.StringBlock.get(StringBlock.java:64)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.content.res.XmlBlock $ Parser.getPooledString(XmlBlock.java:458)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.content.res.TypedArray.loadStringValueAt(TypedArray.java:720)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.content.res.TypedArray.getString(TypedArray.java:124)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.widget.TextView<&初始化GT;(TextView.java:928)11月7日至20日:55:10.467 E / AndroidRuntime(4886):在android.widget.TextView<&初始化GT;(TextView.java:578)11月7日至20日:55:10.467 E / AndroidRuntime(4886):31 ...更多11月7日至20日:55:10.475 W / ActivityManager(459):强制完成活动AndroidApp / AndroidBase.SettingsView11月7日至20日:55:10.998 W / ActivityManager(459):为ActivityRecord活动暂停超时{4294d660 U0 AndroidApp / AndroidBase.SettingsView}


解决方案

解决了我们的问题通过的感谢洛里什这里回答:<一href=\"https://stackoverflow.com/questions/24083744/inflate-exception-on-setting-up-a-long-click-event-listener/24452760#24452760\">Inflate有关设置长按事件侦听器异常

基本上更名为应用程序的一部分有些款式有安卓fontFamily中添加物品。奇怪的是这不仅造成长期的点击崩溃的nexus7片,继续对三星Galaxy Tab做工精细,一加手机等。

I have a dialog fragment with editable text. When you long press on the text it crashes the app. Not sure why this has suddenly started happening as it used to work fine but now crashes consistently, and not too sure where to look as logcat seems to imply it's trying to inflate a view for a long click.

Here's the simple dialog fragment creation (MobileAlertDialog inherits from DialogFragment with a few defaults set)

var alertDialog = new Widgets.MobileAlertDialogFragment();
            alertDialog.Title = s.Name;
            EditText input = new EditText(this);
            (input as EditText).Text = s.Value;
            alertDialog.MessageView = input;
            alertDialog.PositiveCallback = () =>
            {
              s.Value = input.Text;
              RefreshSettings();
            };
            alertDialog.CancelCallback = () =>
            {
              //Do nothing...
            };
            alertDialog.Show(this.SupportFragmentManager, "ENTER_VALUE_DIALOG");

And here's the logcat:

--------- beginning of /dev/log/main

07-20 11:55:10.459 D/AndroidRuntime( 4886): Shutting down VM

07-20 11:55:10.459 W/dalvikvm( 4886): threadid=1: thread exiting with uncaught exception (group=0x41fe8930)

--------- beginning of /dev/log/system

07-20 11:55:10.467 E/AndroidRuntime( 4886): FATAL EXCEPTION: main

07-20 11:55:10.467 E/AndroidRuntime( 4886): android.view.InflateException: Binary XML file line #31: Error inflating class <unknown>

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.LayoutInflater.createView(LayoutInflater.java:613)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at com.android.internal.widget.ActionBarContextView.initForMode(ActionBarContextView.java:206)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2305)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2243)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:623)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:623)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:623)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:623)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:623)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.View.startActionMode(View.java:4302)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.widget.Editor.startSelectionActionMode(Editor.java:1517)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.widget.Editor.performLongClick(Editor.java:839)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.widget.TextView.performLongClick(TextView.java:8066)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.View$CheckForLongPress.run(View.java:17351)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.os.Handler.handleCallback(Handler.java:725)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.os.Handler.dispatchMessage(Handler.java:92)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.os.Looper.loop(Looper.java:137)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.app.ActivityThread.main(ActivityThread.java:5041)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at java.lang.reflect.Method.invokeNative(Native Method)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at java.lang.reflect.Method.invoke(Method.java:511)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at dalvik.system.NativeStart.main(Native Method)

07-20 11:55:10.467 E/AndroidRuntime( 4886): Caused by: java.lang.reflect.InvocationTargetException

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at java.lang.reflect.Constructor.constructNative(Native Method)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.view.LayoutInflater.createView(LayoutInflater.java:587)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     ... 28 more

07-20 11:55:10.467 E/AndroidRuntime( 4886): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=24; index=2231

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.content.res.StringBlock.get(StringBlock.java:64)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:720)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.content.res.TypedArray.getString(TypedArray.java:124)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.widget.TextView.<init>(TextView.java:928)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     at android.widget.TextView.<init>(TextView.java:578)

07-20 11:55:10.467 E/AndroidRuntime( 4886):     ... 31 more

07-20 11:55:10.475 W/ActivityManager(  459):   Force finishing activity AndroidApp/AndroidBase.SettingsView

07-20 11:55:10.998 W/ActivityManager(  459): Activity pause timeout for ActivityRecord{4294d660 u0 AndroidApp/AndroidBase.SettingsView}

解决方案

Solved our issue thanks to answer by Loures here: Inflate Exception on setting up a long click event listener

Basically as part of rebranding app some styles got android:fontFamily items added. Weird thing was this only caused long-click crashing for nexus7 tablets, continued to work fine on Samsung Galaxy Tab, OnePlus One etc.

这篇关于在EditText上Android应用程序崩溃时,长按文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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