java.lang.IllegalStateException: focus search returned a view that wasn't able to take focus!

使用EditText时碰到的一个错误,调试信息如下:

02-10 10:31:58.832: E/AndroidRuntime(802): FATAL EXCEPTION: main
02-10 10:31:58.832: E/AndroidRuntime(802): Process: com.yulore.yellowpage, PID: 802
02-10 10:31:58.832: E/AndroidRuntime(802): java.lang.IllegalStateException: focus search returned a view that wasn't able to take focus!
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.widget.TextView.onKeyUp(TextView.java:5659)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.KeyEvent.dispatch(KeyEvent.java:2664)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.View.dispatchKeyEvent(View.java:7665)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1408)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1408)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1408)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1408)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1408)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1408)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2035)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1505)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.app.Activity.dispatchKeyEvent(Activity.java:2418)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1962)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3852)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3826)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3525)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3582)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5602)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5582)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5553)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3190)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.os.Handler.dispatchMessage(Handler.java:102)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.os.Looper.loop(Looper.java:136)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at android.app.ActivityThread.main(ActivityThread.java:5017)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at java.lang.reflect.Method.invokeNative(Native Method)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at java.lang.reflect.Method.invoke(Method.java:515)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-10 10:31:58.832: E/AndroidRuntime(802): 	at dalvik.system.NativeStart.main(Native Method)

因为我当前的Activity中只有一个EditText能获取到焦点,所以当点击输入法右下角的next时,EditText的右边(或下方)控件不能获取焦点,所以就出现了上述错误。

解决办法

把EditText的android:imeOptions="actionNone" 即可,如下:

<EditText
                android:id="@id/et_search"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:layout_toLeftOf="@id/iv_search_delete"
                android:layout_toRightOf="@id/iv_sc"
                android:background="@null"
                android:hint="@string/search_tips"
                android:singleLine="true"
                android:textColorHint="@color/light_gray"
                android:textSize="@dimen/fontsize_14" 
                android:imeOptions="actionNone"/>








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值