搜索后,Android搜索小部件会在触摸时崩溃

时间:2015-12-17 07:24:57

标签: android search android-actionbar

在我的活动中,我在操作栏中有一个搜索小部件。单击搜索图标会展开搜索视图,当用户键入测试时,将根据文本过滤列表。所有这些功能都很有效。搜索一次如果我们触摸搜索视图以编辑搜索字符串,应用程序崩溃。第一次搜索后的任何触摸事件都会崩溃。

SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search)
            .getActionView();
    searchView.setSearchableInfo(searchManager
            .getSearchableInfo(getComponentName()));
   searchView.setOnQueryTextListener(this);
    MenuItem menuItem = menu.findItem(R.id.search);
    menuItem.setOnActionExpandListener(new OnActionExpandListener() {...

这可能是什么原因。

searchable.xml

 <?xml version="1.0" encoding="utf-8"?>

<searchable xmlns:android="http://schemas.android.com/apk/res/android"
        android:label="@string/app_name"
        />

optionsmenu:

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
    android:id="@+id/search"
    android:actionViewClass="android.widget.SearchView"
    android:icon="@drawable/btn_search_bg"
    android:showAsAction="collapseActionView|ifRoom"
    android:title="@string/search_title"/>
 <item
    android:id="@+id/miActionProgress"
    android:title="Loading..."
    android:visible="false"
    android:showAsAction="ifRoom"
    android:actionLayout="@layout/action_view_progress" />

日志显示`12-17 11:23:04.249 32561-32561E / InputEventReceiver:异常调度输入事件。 12-17 11:23:04.249 32561-32561 E / MessageQueue-JNI:MessageQueue回调中的异常:handleReceiveCallback 12-17 11:23:04.254 32561-32561 E / MessageQueue-JNI:android.content.res.Resources $ NotFoundException:Resource ID#0x0             在android.content.res.Resources.getValue(Resources.java:1416)             在android.content.res.Resources.getDrawable(Resources.java:861)             在android.content.Context.getDrawable(Context.java:402)             在android.widget.Editor $ InsertionPointCursorController.getHandle(Editor.java:3883)             在android.widget.Editor $ InsertionPointCursorController.show(Editor.java:3862)             在android.widget.Editor.onTouchUpEvent(Editor.java:1670)             在android.widget.TextView.onTouchEvent(TextView.java:8274)             在android.view.View.dispatchTouchEvent(View.java:8486)             在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2541)             在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2234)             在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2541)             在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2234)             在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2541)             在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2234)             在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2541)             在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2234)             在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2541)             在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2234)             在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2541)             在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2234)             在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2541)             在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2234)             在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2541)             在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2234)             在

0 个答案:

没有答案