當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchView.setOnQueryTextListener方法代碼示例

本文整理匯總了Java中android.widget.SearchView.setOnQueryTextListener方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchView.setOnQueryTextListener方法的具體用法?Java SearchView.setOnQueryTextListener怎麽用?Java SearchView.setOnQueryTextListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.SearchView的用法示例。


在下文中一共展示了SearchView.setOnQueryTextListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuInflater menuInflater = new MenuInflater(rootView.getContext());
    menuInflater.inflate(R.menu.menu_ventas_lista, menu);
    MenuItem item = menu.findItem(R.id.item_buscar);
    SearchView searchView = (SearchView)item.getActionView();

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }
        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    super.onCreateOptionsMenu(menu, inflater);

}
 
開發者ID:EdwardAlexis,項目名稱:Sistema-de-Comercializacion-Negocios-Jhordan,代碼行數:21,代碼來源:ViewPagerVentasLista.java

示例2: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.content_actions, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    Intent shareIntent = new org.bbs.apklauncher.emb.IntentHelper(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    actionProvider.setShareIntent(shareIntent);
    return true;
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:21,代碼來源:SystemUIModes.java

示例3: configureFolderSearchView

import android.widget.SearchView; //導入方法依賴的package包/類
private void configureFolderSearchView(Menu menu) {
    final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
    final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
    folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
    folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            folderMenuItem.collapseActionView();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mAdapter.getFilter().filter(newText);
            return true;
        }
    });
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:20,代碼來源:ChooseFolder.java

示例4: initQueryTextListener

import android.widget.SearchView; //導入方法依賴的package包/類
private void initQueryTextListener(SearchView searchView) {

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

                return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {

                IconsSearchUtils.filter(newText, matchingIcons, allIcons, mGridAdapter);
                return true;
            }
        });
    }
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:18,代碼來源:IconChooser.java

示例5: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.menu_main, menu);

    menu.findItem(R.id.item_show_system).setChecked(mSharedPreferences.getBoolean(PREF_SHOW_SYSTEM, false));
    menu.findItem(R.id.item_show_toast).setChecked(mSharedPreferences.getBoolean(PREF_TOAST, true));
    mSearchView = (SearchView) menu.findItem(R.id.item_search).getActionView();
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            filterApps(app -> app.name.toLowerCase().contains(query.toLowerCase()) || app.packageName.toLowerCase().contains(query.toLowerCase()));
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            filterApps(app -> app.name.toLowerCase().contains(newText.toLowerCase()) || app.packageName.toLowerCase().contains(newText.toLowerCase()));
            return true;
        }
    });
    return true;
}
 
開發者ID:Kuanghusing,項目名稱:NeverCrash,代碼行數:24,代碼來源:MainActivity.java

示例6: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);

    searchItem = menu.findItem(R.id.search);
    searchView = (SearchView) searchItem.getActionView();

    if (searchView != null)
    {
        searchView.setSubmitButtonEnabled(true);
        searchView.setImeOptions(EditorInfo.IME_ACTION_GO);
        searchView.setOnQueryTextListener(new QueryTextListener());
    }

    return true;
}
 
開發者ID:billthefarmer,項目名稱:editor,代碼行數:19,代碼來源:Editor.java

示例7: onResume

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public void onResume() {
    super.onResume();
    List<File> containers = FileUtils.getContainers(getActivity());

    final ContainerListAdapter containerListAdapter = new ContainerListAdapter(getActivity(), containers);
    setListAdapter(containerListAdapter);

    SearchView searchView = (SearchView) getActivity().findViewById(R.id.listSearch);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            containerListAdapter.getFilter().filter(newText);
            return false;
        }
    });
    searchView.setQuery("", false);
    getActivity().findViewById(R.id.content_browse_containers).requestFocus();
}
 
開發者ID:open-eid,項目名稱:MOPP-Android,代碼行數:25,代碼來源:BrowseContainersListFragment.java

示例8: onCreateView

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_home_list, container, false);
    final ListView recipeList = (ListView) view.findViewById(R.id.list_view);
    recipeList.setAdapter(new RecipeListAdapter(getActivity(), mRecipes));
    // Configure list for testing
    recipeList.setTag(R.id.test_tag_recipe_list, "Recipe List");
    
    // Search
    mSearchView = (SearchView) view.findViewById(R.id.search);
    mSearchView.setOnQueryTextListener(new SearchHandler());

    // Empty view, shown when list is empty
    final TextView emptyView = (TextView) view.findViewById(R.id.empty_list_view);
    emptyView.setText(R.string.no_recipes);
    if (mRecipes.isEmpty()) {
        emptyView.setVisibility(View.VISIBLE);
    } else {
        emptyView.setVisibility(View.INVISIBLE);
    }
    mRecipes.addOnListChangedCallback(new ListEmptyViewManager(emptyView));

    return view;
}
 
開發者ID:Cook-E-team,項目名稱:Cook-E,代碼行數:27,代碼來源:RecipeList.java

示例9: fromView

import android.widget.SearchView; //導入方法依賴的package包/類
public static Observable<String> fromView(SearchView searchView) {

        final PublishSubject<String> subject = PublishSubject.create();

        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String s) {
                subject.onComplete();
                return true;
            }

            @Override
            public boolean onQueryTextChange(String text) {
                subject.onNext(text);
                return true;
            }
        });

        return subject;
    }
 
開發者ID:amitshekhariitbhu,項目名稱:RxJava2-Android-Samples,代碼行數:21,代碼來源:RxSearchObservable.java

示例10: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setIconifiedByDefault(false);

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            model.search(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return true;
        }
    });
}
 
開發者ID:dream83619,項目名稱:GoogleBookReader-android,代碼行數:24,代碼來源:BookListFragment.java

示例11: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.content_actions, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    actionProvider.setShareIntent(shareIntent);
    return true;
}
 
開發者ID:Sherchen,項目名稱:ApiDemos,代碼行數:21,代碼來源:SystemUIModes.java

示例12: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu){

    MenuInflater inflater = getMenuInflater();
    inflater.inflate (R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = menu.findItem(R.id.search_bar);

    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    searchView.setSubmitButtonEnabled(false);
    searchView.setOnQueryTextListener(this);

    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:Shaderboy,項目名稱:V-Scan,代碼行數:18,代碼來源:Lookup.java

示例13: onCreate

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    final SearchView searchView = (SearchView)findViewById(R.id.homeSearch);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            Intent intent = new Intent(searchView.getContext(), SearchActivity.class);
            intent.setAction(Intent.ACTION_SEARCH);
            intent.putExtra(SearchManager.QUERY, query);
            startActivity(intent);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
}
 
開發者ID:googlesamples,項目名稱:io2015-codelabs,代碼行數:23,代碼來源:HomeActivity.java

示例14: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    inflater.inflate(R.menu.menu_tab_detalhe_evento_programacao, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search_tab_detalhe_programacao);
    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setOnQueryTextListener(mQueryTextListenerTalk);

    searchView.setOnCloseListener(new SearchView.OnCloseListener() {
        @Override
        public boolean onClose() {
            ArrayList<Talk> list_talk = new ArrayList<Talk>();

            list_talk = (ArrayList<Talk>) new TalkDao(getActivity().getApplicationContext()).getListTalkForEventIdTAB_TALK(Long.parseLong(obj_event.id));

            agrupamento(getActivity().getApplicationContext(), list_talk, false);

            adapterTalk.notifyDataSetChanged();

            return false;
        }
    });
}
 
開發者ID:Makadu,項目名稱:Makadu_Android,代碼行數:26,代碼來源:Tab_EventDetail_Talk_Paper.java

示例15: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu_context) {
    getMenuInflater().inflate(R.menu.menu_principal, menu_context);

    MenuItem searchItem = menu_context.findItem(R.id.action_search_main);
    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setOnQueryTextListener(mQueryTextListener);

    searchView.setOnCloseListener(new SearchView.OnCloseListener() {
        @Override
        public boolean onClose() {

            ArrayList<Event> list_event = new ArrayList<Event>();

            list_event = (ArrayList<Event>) new EventDao(getApplication().getApplicationContext()).getAll();

            mAdapterTodosEventos.setData(list_event);
            mAdapterTodosEventos.notifyDataSetChanged();

            return false;
        }
    });

    return true;
}
 
開發者ID:Makadu,項目名稱:Makadu_Android,代碼行數:26,代碼來源:Tab_Main.java


注:本文中的android.widget.SearchView.setOnQueryTextListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。