在edittext中长按文本时Android应用程序崩溃

时间:2015-07-20 11:28:57

标签: c# android android-fragments xamarin

我有一个带有可编辑文本的对话框片段。当您长按文本时,它会崩溃应用程序。不知道为什么这突然发生,因为它曾经工作正常,但现在崩溃一致,并不太确定在哪里看起来像logcat似乎意味着它试图通过长时间点击膨胀视图。

这是简单的对话框片段创建(MobileAlertDialog继承自DialogFragment并设置了一些默认值)

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");

这是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}

1 个答案:

答案 0 :(得分:0)

感谢Loures在这里回答我们的问题:Inflate Exception on setting up a long click event listener

基本上作为品牌重塑应用程序的一部分,一些样式添加了android:fontFamily项目。奇怪的是,这只会导致nexus7平板电脑的长时间点击崩溃,继续在三星Galaxy Tab,OnePlus One上正常工作。