SearchViewHatası
20.05.2017 - 10:03
Uygulamamda SearchView kullanıyorum ama sürekli hata göndürüyor.
public class MainHome extends Fragment{
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(fragId, container, false);
setHasOptionsMenu(true);
return view;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_show_case, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
if (searchView != null) {
SearchManager manager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(manager.getSearchableInfo(getActivity().getComponentName()));
searchView.setQueryHint(getString(R.string.search_view_hint));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
newSearch();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText.isEmpty()) {
searchWord = "";
} else {
searchWord = newText.replace(" ", "%20");
}
return false;
}
});
MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
searchWord = "";
newSearch();
return true;
}
});
}
super.onCreateOptionsMenu(menu, inflater);
}
}
at com.applodesnos.MainHome.onCreateOptionsMenu(MainHome.java:242)
at android.support.v4.app.Fragment.performCreateOptionsMenu(Fragment.java:2059)
at android.support.v4.app.FragmentManagerImpl.dispatchCreateOptionsMenu(FragmentManager.java:2118)
at android.support.v4.app.FragmentController.dispatchCreateOptionsMenu(FragmentController.java:279)
at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:341)
at android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:85)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onCreatePanelMenu(AppCompatDelegateImplBase.java:241)
at android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:85)
at android.support.v7.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:443)
at android.support.v7.app.ToolbarActionBar$1.run(ToolbarActionBar.java:60)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7231)
at java.lang.reflect.Method.invoke(Native Method:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
5
Görüntülenme
0 Beğeni