当前位置: 首页>>代码示例>>Java>>正文


Java SearchView.setQuery方法代码示例

本文整理汇总了Java中android.widget.SearchView.setQuery方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setQuery方法的具体用法?Java SearchView.setQuery怎么用?Java SearchView.setQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.SearchView的用法示例。


在下文中一共展示了SearchView.setQuery方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: onFocusChange

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onFocusChange(View view, boolean hasFocus) {
    if(!(view instanceof SearchView)){
        return;
    }

    mIsExpand = hasFocus;

    SearchView searchView = (SearchView)view;
    ViewGroup.LayoutParams lp = searchView.getLayoutParams();
    if(lp != null){
        lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
    }

    searchView.setQuery(mSearchText, false);
}
 
开发者ID:DmitriyG1,项目名称:vk-music-player-android,代码行数:17,代码来源:VKSearchFragment.java

示例3: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.searchview_in_menu, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) searchItem.getActionView();
    setupSearchView(searchItem);

    if (mQuery != null) {
        mSearchView.setQuery(mQuery, false);
    }

    return true;
}
 
开发者ID:googlesamples,项目名称:io2015-codelabs,代码行数:17,代码来源:SearchActivity.java

示例4: onPrepareOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onPrepareOptionsMenu(Menu menu) {
    final MenuItem searchItem = menu.findItem(R.id.action_lookup);

    searchView = (SearchView)searchItem.getActionView();
    searchView.setOnQueryTextListener(this);

    if(openSearch){
        searchView.setIconified(false);
        searchView.setQuery(textQuery,false);
        searchView.requestFocus();
    }
}
 
开发者ID:duniter,项目名称:duniter-android-app,代码行数:14,代码来源:IdentityListFragment.java

示例5: onCreateOptionsMenu

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

    inflater.inflate(R.menu.vk_search_menu, menu);
    MenuItem menuItem = menu.findItem(R.id.vk_search);
    menuItem.setOnActionExpandListener(this);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
    searchView.setOnQueryTextListener(this);
    searchView.setOnQueryTextFocusChangeListener(this);
    searchView.setQuery(mSearchText, false);
    searchView.setIconifiedByDefault(false);
}
 
开发者ID:DmitriyG1,项目名称:vk-music-player-android,代码行数:14,代码来源:VKSearchFragment.java

示例6: makeSearchMenuEntry

import android.widget.SearchView; //导入方法依赖的package包/类
@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;
}
 
开发者ID:IvanVolosyuk,项目名称:diskusage,代码行数:39,代码来源:DiskUsageMenuHoneycomb.java

示例7: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_add_remove_fragment, menu);
    // Setup SearchView
    SearchManager searchManager = (SearchManager)getActivity().getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = menu.findItem(R.id.search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            networkRecyclerAdapter.getFilter().filter(newText);
            return true;
        }
    });
    // Recreate the last search if the screen was rotated
    if(last_filter_term != null && last_filter_term.length() > 0){
        searchView.setQuery(last_filter_term, true);
        searchView.setIconified(false);
        searchView.clearFocus();
    }
}
 
开发者ID:WIStudent,项目名称:FreifunkAutoConnectApp,代码行数:28,代码来源:AddRemoveNetworksFragment.java

示例8: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_manage_poi, menu);

    final MenuItem searchItem = menu.findItem(R.id.action_search);
    searchView = (SearchView) searchItem.getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            onQueryTextChange(query);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            typesAdapter.getFilter().filter(newText);
            filterConstraint = newText;
            return true;
        }
    });
    if (!showingTypes) {
        searchView.setVisibility(View.GONE);
    }
    if (showingTypes && !StringUtils.isEmpty(filterConstraint)) {
        searchView.setIconified(false);
        searchView.setQuery(filterConstraint, true);
    }
    return true;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:30,代码来源:TypeListActivity.java

示例9: query

import android.widget.SearchView; //导入方法依赖的package包/类
/**
 * An action which sets the query property of {@code view} with character sequences.
 * <p>
 * <em>Warning:</em> The created observable keeps a strong reference to {@code view}. Unsubscribe
 * to free this reference.
 *
 * @param submit whether to submit query right after updating query text
 */
@CheckResult @NonNull
public static Consumer<? super CharSequence> query(@NonNull final SearchView view,
    final boolean submit) {
  checkNotNull(view, "view == null");
  return new Consumer<CharSequence>() {
    @Override public void accept(CharSequence text) {
      view.setQuery(text, submit);
    }
  };
}
 
开发者ID:JakeWharton,项目名称:RxBinding,代码行数:19,代码来源:RxSearchView.java

示例10: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
{
    super.onCreateOptionsMenu(menu,inflater);
    inflater.inflate(R.menu.contact_list_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.menu_search);

    final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);

    final SearchView searchView = (SearchView) searchItem.getActionView();

    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));

    searchView.setOnQueryTextListener(
            new SearchView.OnQueryTextListener() {

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

                @Override
                public boolean onQueryTextChange(String newText) {

                    String newFilter = !TextUtils.isEmpty(newText) ? newText : null;

                    if (mSearchTerm == null && newFilter == null) {
                        return true;
                    }

                    if (mSearchTerm != null && mSearchTerm.equals(newFilter)) {
                        return true;

                    }

                    mSearchTerm = newFilter;
                    mSearchQueryChanged = true;

                    getLoaderManager().restartLoader(ContactsQuery.QUERY_ID, null, ContactsFragment.this);

                    return true;

                }
            }
    );
    if (mSearchTerm != null)
    {
        final String savedSearchTerm = mSearchTerm;
        searchItem.expandActionView();

        searchView.setQuery(savedSearchTerm, false);
    }


}
 
开发者ID:sflores01,项目名称:DoNotDisturb,代码行数:57,代码来源:ContactsFragment.java


注:本文中的android.widget.SearchView.setQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。