Java 类android.widget.SearchView.OnQueryTextListener 实例源码

项目:kluster-android    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main_menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();

    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {

            Bundle bundle = new Bundle();
            bundle.putString("query", query);

            Fragment fragment = new SearchFragment();
            fragment.setArguments(bundle);
            FragmentManager fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction().replace(R.id.main_container, fragment).commit();
            return true;
        }
        @Override
        public boolean onQueryTextChange(String newText) {
            return true;
        }
    });

    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default

    return true;
}
项目:AndroidAdapters    文件:MainActivity.java   
/**
 * Creates and returns a listener, which allows to start a search query when the user enters
 * text.
 *
 * @return The listener, which has been created, as an instance of the type {@link
 * OnQueryTextListener}
 */
private OnQueryTextListener createSearchQueryListener() {
    return new OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(final String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(final String newText) {
            search(newText);
            return true;
        }

    };
}
项目:Jahamanga    文件:SearchMangaActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // TODO Auto-generated method stub
    getMenuInflater().inflate(R.menu.main, menu);
    SearchManager searchManager = (SearchManager) this.getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView =
            (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setQueryHint(getResources().getText(R.string.search_hint));
    searchView.setSearchableInfo(
            searchManager.getSearchableInfo(this.getComponentName()));
    searchView.setOnQueryTextListener(new OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            // TODO Auto-generated method stub
            return false;
        }
    });

    return super.onCreateOptionsMenu(menu);
}
项目:boohee_v5.6    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:permissionsModule    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:diskusage    文件:DiskUsageMenuHoneycomb.java   
@Override
public MenuItem makeSearchMenuEntry(Menu menu) {
  MenuItem item = menu.add("Search");
  searchView = new SearchView(diskusage);
  origSearchBackground = searchView.getBackground();
  item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
  item.setIcon(android.R.drawable.ic_search_category_default);
  item.setActionView(searchView);
  if (searchPattern != null) {
    searchView.setIconified(false);
    searchView.setQuery(searchPattern, false);
  }
  searchView.setOnCloseListener(new OnCloseListener() {
    @Override
    public boolean onClose() {
      Log.d("diskusage", "search closed");
      searchPattern = null;
      diskusage.applyPatternNewRoot(masterRoot, null);
      return false;
    }
  });
  searchView.setOnQueryTextListener(new OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      onQueryTextChange(query);
      return false;
    }

    @Override
    public boolean onQueryTextChange(String newText) {
      Log.d("diskusage", "search query changed to: " + newText);
      searchPattern = newText;
      applyPattern(searchPattern);
      return true;
    }
  });
  return item;
}
项目:ShoppingMall    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:CodenameOne    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:adt-leanback-support    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:informant-droid    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:nextgislogger    文件:MarkActivity.java   
@Override
   public boolean onCreateOptionsMenu(final Menu menu) {
       getMenuInflater().inflate(R.menu.mark, menu);
       mBtRetry = menu.findItem(R.id.bt_lost);
    mSearchBox = menu.findItem(R.id.search);

       mSearchView = (SearchView) mSearchBox.getActionView();
       mSearchView.setQueryHint(getString(R.string.mark_editor_hint));

       mSearchView.setOnSearchClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               setItemsVisibility(menu, mSearchBox, false);
               mSearchView.requestFocus();
           }
       });

    mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
           @Override
           public boolean onClose() {
               setItemsVisibility(menu, mSearchBox, true);
               return false;    // true = prevent collapse mSearchView
           }
       });

    mSearchView.setOnQueryTextListener(new OnQueryTextListener() {
           @Override
           public boolean onQueryTextSubmit(String query) {
               return false;
           }

           @Override
           public boolean onQueryTextChange(String newText) {
               mMarksAdapter.getFilter().filter(newText);
               return true;
           }
       });

    return true;
}
项目:DiskUsage.0    文件:DiskUsageMenuHoneycomb.java   
@Override
public MenuItem makeSearchMenuEntry(Menu menu) {
  MenuItem item = menu.add("Search");
  searchView = new SearchView(diskusage);
  origSearchBackground = searchView.getBackground();
  item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
  item.setIcon(android.R.drawable.ic_search_category_default);
  item.setActionView(searchView);
  if (searchPattern != null) {
    searchView.setIconified(false);
    searchView.setQuery(searchPattern, false);
  }
  searchView.setOnCloseListener(new OnCloseListener() {
    @Override
    public boolean onClose() {
      Log.d("diskusage", "search closed");
      searchPattern = null;
      diskusage.applyPatternNewRoot(masterRoot, null);
      return false;
    }
  });
  searchView.setOnQueryTextListener(new OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      onQueryTextChange(query);
      return false;
    }

    @Override
    public boolean onQueryTextChange(String newText) {
      Log.d("diskusage", "search query changed to: " + newText);
      searchPattern = newText;
      applyPattern(searchPattern);
      return true;
    }
  });
  return item;
}
项目:Jahamanga    文件:MangaListFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // TODO Auto-generated method stub
    mActivity.getMenuInflater().inflate(R.menu.main, menu);
    SearchManager searchManager = (SearchManager) mActivity.getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView =
            (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setQueryHint(getResources().getText(R.string.search_hint));
    searchView.setSearchableInfo(
            searchManager.getSearchableInfo(mActivity.getComponentName()));
    searchView.setOnQueryTextListener(new OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            // TODO Auto-generated method stub
            Intent i = new Intent(mActivity, SearchMangaActivity.class);
            i.putExtra(SearchMangaActivity.ARG_MANGA_KEYWORD, query);
            startActivity(i);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            // TODO Auto-generated method stub
            return false;
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}
项目:bitcast    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:V.FlyoutTest    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:guideshow    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:IntranetEpitechV2    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:MoSeS--Client-    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:smsnenado    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    mSearchView = (SearchView)
        menu.findItem(R.id.search_MenuItem).getActionView();
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {
            LOGI("onQueryTextChange newText='" + newText + "'" +
                 " filter='" + getSearchFilter() + "'");
            if (!equalFilters(mLastRequestedFilter, getSearchFilter())) {
                refreshSmsItemAdapter();
            }
            return true;
        }

        public boolean onQueryTextSubmit(String query) {
            LOGI("onQueryTextSubmit query='" + query + "'" +
                 " filter='" + getSearchFilter() + "'");
            if (!equalFilters(mLastRequestedFilter, getSearchFilter())) {
                refreshSmsItemAdapter();
            }
            return true;
        }
    });

    updateOptionsMenu(menu);

    return true;
}
项目:android.support.v4    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:Joszolgalat_Android_App    文件:SearchViewCompatHoneycomb.java   
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
项目:boohee_v5.6    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:permissionsModule    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:AbacusUtil    文件:Observer.java   
public Disposable onQueryTextChange(final Consumer<? super String> onNext, final Consumer<? super Exception> onError, final Runnable onComplete) {
    N.requireNonNull(onNext, "onNext");
    N.requireNonNull(onError, "onError");
    N.requireNonNull(onComplete, "onComplete");

    dispatcher.append(new DispatcherBase<Object>(onError, onComplete) {
        @Override
        public void onNext(Object param) {
            @SuppressWarnings("unchecked")
            final String tmp = (String) param;

            if (Fu.isUiThread()) {
                onNext.accept(tmp);
            } else {
                UIExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        onNext.accept(tmp);
                    }
                });
            }
        }
    });

    _view.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            dispatcher.onNext(newText);
            return true;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            // Do nothing.
            return false;
        }
    });

    disposeActions.add(new Runnable() {
        @Override
        public void run() {
            _view.setOnQueryTextListener(null);
        }
    });

    return this;
}
项目:AbacusUtil    文件:Observer.java   
public Disposable onQueryTextSubmit(final Consumer<? super String> onNext, final Consumer<? super Exception> onError, final Runnable onComplete) {
    N.requireNonNull(onNext, "onNext");
    N.requireNonNull(onError, "onError");
    N.requireNonNull(onComplete, "onComplete");

    dispatcher.append(new DispatcherBase<Object>(onError, onComplete) {
        @Override
        public void onNext(Object param) {
            @SuppressWarnings("unchecked")
            final String tmp = (String) param;

            if (Fu.isUiThread()) {
                onNext.accept(tmp);
            } else {
                UIExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        onNext.accept(tmp);
                    }
                });
            }
        }
    });

    _view.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            // Do nothing.
            return false;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            dispatcher.onNext(query);
            return true;
        }
    });

    disposeActions.add(new Runnable() {
        @Override
        public void run() {
            _view.setOnQueryTextListener(null);
        }
    });

    return this;
}
项目:AbacusUtil    文件:Observer.java   
public Disposable onQueryText(final OnQueryTextListener onNext) {
    return onQueryText(onNext, Fu.ON_ERROR_MISSING);
}
项目:AbacusUtil    文件:Observer.java   
public Disposable onQueryText(final OnQueryTextListener onNext, final Consumer<? super Exception> onError) {
    return onQueryText(onNext, onError, Fu.EMPTY_ACTION);
}
项目:AbacusUtil    文件:Observer.java   
public Disposable onQueryText(final OnQueryTextListener onNext, final Consumer<? super Exception> onError, final Runnable onComplete) {
    N.requireNonNull(onNext, "onNext");
    N.requireNonNull(onError, "onError");
    N.requireNonNull(onComplete, "onComplete");

    dispatcher.append(new DispatcherBase<Object>(onError, onComplete) {
        @Override
        public void onNext(Object param) {
            @SuppressWarnings("unchecked")
            final Tuple2<Integer, String> tmp = (Tuple2<Integer, String>) param;

            if (Fu.isUiThread()) {
                if (tmp._1 == 0) {
                    onNext.onQueryTextChange(tmp._2);
                } else {
                    onNext.onQueryTextSubmit(tmp._2);
                }
            } else {
                UIExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        if (tmp._1 == 0) {
                            onNext.onQueryTextChange(tmp._2);
                        } else {
                            onNext.onQueryTextSubmit(tmp._2);
                        }
                    }
                });
            }
        }
    });

    _view.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            dispatcher.onNext(Tuple.of(0, newText));
            return true;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            dispatcher.onNext(Tuple.of(1, query));
            return true;
        }
    });

    disposeActions.add(new Runnable() {
        @Override
        public void run() {
            _view.setOnQueryTextListener(null);
        }
    });

    return this;
}
项目:ShoppingMall    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:CodenameOne    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:adt-leanback-support    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:informant-droid    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:bitcast    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:V.FlyoutTest    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:guideshow    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:IntranetEpitechV2    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:MoSeS--Client-    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:Android-LensRocket    文件:FriendsListActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.friends_list, menu);       
    // Associate searchable configuration with the SearchView
    SearchManager searchManager =
           (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView =
            (SearchView) menu.findItem(R.id.menuSearch).getActionView();
    mSearchView.setSearchableInfo(
            searchManager.getSearchableInfo(getComponentName()));       
    mSearchView.setOnQueryTextListener(new OnQueryTextListener() {          
            @Override
        public boolean onQueryTextSubmit(String query) {
            return true;
        }

        @Override
        public boolean onQueryTextChange(final String newText) {
            LensRocketLogger.i(TAG, "Text: " + newText);
            mCurrentName = newText;
            mBtnAddFriend.setEnabled(true);
            mBtnAddFriend.setVisibility(View.VISIBLE);              
            mAdapter.getFilter().filter(newText, new FilterListener() {                 
                @Override
                public void onFilterComplete(int count) {
                    if (mAdapter.getCount() > 0) 
                        mLvFriends.setVisibility(View.VISIBLE);
                    else
                        mLvFriends.setVisibility(View.GONE);

                    if (!mCurrentName.equals("")) {
                        mLayoutAddFriend.setVisibility(View.VISIBLE);
                    } else {
                        mLayoutAddFriend.setVisibility(View.GONE);
                    }                   
                    if (mLensRocketService.getLocalFriendNames().contains(newText))
                        mLayoutAddFriend.setVisibility(View.GONE);
                }
            });
            mLblNewFriendName.setText(mCurrentName);                                
            return true;
        }
    });     
    return true;
}
项目:android.support.v4    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
项目:Joszolgalat_Android_App    文件:SearchViewCompatHoneycomb.java   
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}