2017-09-21 12 views
-1

this linkから電子商取引のデモを実行しようとしましたが、これはカスタムアクションバーの検索バーを設定し、そのフラグメントのhit_item UIを呼び出して変更しました。しかし、私はこのエラーが発生します:InstantSearchの変更Androidの例で例外が発生する

09-21 19:04:04.393 11716-11716/e_green_book.com.e_green_book E/EventBus: Could not dispatch event: class com.algolia.instantsearch.events.SearchEvent to subscribing class class com.algolia.instantsearch.helpers.SearchProgressController 
java.lang.NullPointerException: Attempt to invoke interface method 'android.view.MenuItem android.view.Menu.findItem(int)' on a null object reference 
    at com.algolia.instantsearch.utils.SearchViewFacade.<init>(SearchViewFacade.java:40) 
    at com.algolia.instantsearch.helpers.InstantSearch.updateProgressBar(InstantSearch.java:420) 
    at com.algolia.instantsearch.helpers.InstantSearch.access$100(InstantSearch.java:47) 
    at com.algolia.instantsearch.helpers.InstantSearch$1.onStart(InstantSearch.java:191) 
    at com.algolia.instantsearch.helpers.SearchProgressController.onSearch(SearchProgressController.java:66) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:485) 
    at org.greenrobot.eventbus.EventBus.postToSubscription(EventBus.java:416) 
    at org.greenrobot.eventbus.EventBus.postSingleEventForEventType(EventBus.java:397) 
    at org.greenrobot.eventbus.EventBus.postSingleEvent(EventBus.java:370) 
    at org.greenrobot.eventbus.EventBus.post(EventBus.java:251) 
    at com.algolia.instantsearch.helpers.Searcher.search(Searcher.java:172) 
    at com.e_commerce.e_green_book.activity.MainActivity.onCreate(MainActivity.java:200) 
    at android.app.Activity.performCreate(Activity.java:6736) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2636) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2744) 
    at android.app.ActivityThread.-wrap12(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1493) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6195) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764) 

このエラーはありますか? InstantSearch Androidを使用するにはどうしたらいいですか?

+0

こんにちはDeep Doshiさん、コードをダウンロードして直接実行しても状況を再現できません。アプリケーションのコードを変更しましたか?あなたはそれをどのプラットフォームで実行していますか? – PLNech

+0

私は、カスタムアクションバーに検索バーを設定し、そのフラグメント内でhit_item UIを呼び出しました。 –

+0

あなたの質問にこのコードを教えてください。 – PLNech

答えて

3

あなたはすぐにInstantSearch Androidを使用できるはずです。

あなたが直面している問題は、あなたがコードを変更するだけを発生した場合、あなたは変更を送信する必要がありあなたの質問に私たちはあなたの特定の状況を把握できるようにします。

共有だけでスタックトレースを使用して、それはあなたがregisterSearchView(activity, menu, id)に渡しているmenu参照がid与えを使用してビューが含まれていないようです:

searchView = (SearchView) menu.findItem(id).getActionView(); 

これはNullPointerExceptionを投げ、あなたがすべきコールのmenuidパラメータをチェックして、メニューに確かにこのidのSearchViewが含まれていることを確認します。

+2

レスポンスのおかげでエラーが解決しました。 –

+1

聞いてうれしい!それが私の答えのおかげですなら、それを受け入れることができますか?それ以外の場合は、エラーの解決方法を教えてください。 – PLNech

関連する問題