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


Java SearchView.setQueryHint方法代码示例

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


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

示例1: onCreateOptionsMenu

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

    sortByName = menu.findItem(R.id.menu_sort_by_name);
    sortByTimeSpent = menu.findItem(R.id.menu_sort_by_time);

    sortByName.setChecked(isSortedByName);
    sortByTimeSpent.setChecked(isSortedByName);

    sortData();

    final MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(context.getString(R.string.search_hint));
    searchView.setOnQueryTextListener(this);
}
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:19,代码来源:ProjectsFragment.java

示例2: onCreateOptionsMenu

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

  // Setup search widget in action bar
  SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
  searchView.setQueryHint(getString(R.string.search_hint));
  searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);

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

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

  return true;
}
 
开发者ID:quangctkm9207,项目名称:mvp-android-arch-component,代码行数:22,代码来源:QuestionsActivity.java

示例3: onCreateOptionsMenu

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

        MenuItem searchItem = menu.findItem(R.id.action_search);
        mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
        mSearchView.setQueryHint("输入歌曲名查找");

        mSearchView.onActionViewExpanded();// 当展开无输入内容的时候,没有关闭的图标
        mSearchView.setIconified(true);//设置searchView处于展开状态

//        searchView.setSubmitButtonEnabled(true);
        mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                //提交按钮的点击事件
                Toast.makeText(SearchViewActivity.this, query, Toast.LENGTH_SHORT).show();
                return true;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                //当输入框内容改变的时候回调
//                Log.i(TAG,"内容: " + newText);
                quertMusic(newText);
                return true;
            }
        });


        mSearchAutoComplete = (SearchView.SearchAutoComplete) mSearchView.findViewById(R.id.search_src_text);

        //设置输入框内容文字和提示文字的颜色
        mSearchAutoComplete.setHintTextColor(getResources().getColor(android.R.color.white));
        mSearchAutoComplete.setTextColor(getResources().getColor(android.R.color.white));

        return super.onCreateOptionsMenu(menu);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:SearchViewActivity.java

示例4: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.song_sort_by, menu);
    searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.song_search));
    searchView.setOnQueryTextListener(this);
    searchView.setQueryHint("Search song");
    menu.findItem(R.id.grid_view).setVisible(false);
    menu.findItem(R.id.menu_sort_by).setVisible(false);
    menu.findItem(R.id.default_folder).setVisible(false);
    menu.findItem(R.id.menu_refresh).setVisible(false);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:13,代码来源:RecentPlayedFragment.java

示例5: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  super.onCreateOptionsMenu(menu);
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.home_menu, menu);
  searchItem = menu.findItem(R.id.search);
  final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
  final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  searchView.setQueryHint(getString(R.string.search_hint));
  searchView.setSearchableInfo(searchManager.getSearchableInfo(
      new ComponentName(this, SearchActivity.class)));
  return true;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:14,代码来源:QuranActivity.java

示例6: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  super.onCreateOptionsMenu(menu);
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.quran_menu, menu);
  final MenuItem item = menu.findItem(R.id.search);
  final SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
  final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  searchView.setQueryHint(getString(R.string.search_hint));
  searchView.setSearchableInfo(searchManager.getSearchableInfo(
      new ComponentName(this, SearchActivity.class)));
  return true;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:14,代码来源:PagerActivity.java

示例7: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.song_sort_by, menu);
    searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.song_search));
    searchView.setOnQueryTextListener(this);
    searchView.setQueryHint("Search song");
    menu.findItem(R.id.grid_view).setVisible(false);
    menu.findItem(R.id.default_folder).setVisible(false);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:11,代码来源:RecentlyAddedFragment.java

示例8: onCreateOptionsMenu

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

    MenuItem searchItem = menu.findItem(R.id.menu_app_search);
    MenuItem filterEnabledAppsItem = menu.findItem(R.id.menu_filter_enabled);

    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getString(R.string.search_query_hint));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return recyclerViewShowSearchResult(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return recyclerViewShowSearchResult(newText);
        }
    });

    searchItem.setEnabled(false);
    filterEnabledAppsItem.setEnabled(false);
    filterEnabledAppsItem.setChecked(mShowOnlyEnabledApps);

    return true;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:28,代码来源:AppChoicesActivity.java

示例9: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_search, menu);
    MenuItem item = menu.findItem(R.id.action_search);
    try {
        SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(item);
        mSearchView.setQueryHint(getString(R.string.search_by_title));
        mSearchView.setInputType(InputType.TYPE_CLASS_TEXT);
        mSearchView.setOnQueryTextListener(this);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:anad7,项目名称:CleanArchitecture,代码行数:14,代码来源:GetMovieFragment.java

示例10: onCreateOptionsMenu

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

    final MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQueryHint(getResources().getString(R.string.search_movies_tv_shows_people));

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            if (!NetworkConnection.isConnected(MainActivity.this)) {
                Toast.makeText(MainActivity.this, R.string.no_network, Toast.LENGTH_SHORT).show();
                return true;
            }
            Intent intent = new Intent(MainActivity.this, SearchActivity.class);
            intent.putExtra(Constant.QUERY, query);
            startActivity(intent);
            searchMenuItem.collapseActionView();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });

    return true;
}
 
开发者ID:hitanshu-dhawan,项目名称:PopCorn,代码行数:31,代码来源:MainActivity.java

示例11: onCreateOptionsMenu

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

    getMenuInflater().inflate(R.menu.search_navigation, menu);
    MenuItem searchViewItem = menu.findItem(R.id.action_search);

    SearchManager searchManager =
            (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) searchViewItem.getActionView();
    searchView.setQueryHint("Search");
    searchView.setSearchableInfo(searchManager
            .getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);// Do not iconify the widget; expand it by defaul

    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {
            // Adapter that will be filtered
            classAdapter.getFilter().filter(newText);
            return true;
        }

        public boolean onQueryTextSubmit(String query) {

            return true;
        }
    };

    searchView.setOnQueryTextListener(queryTextListener);
    return true;
}
 
开发者ID:fga-gpp-mds,项目名称:2017.1-Trezentos,代码行数:31,代码来源:SearchActivity.java

示例12: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.menu_search, menu);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQueryHint(getString(R.string.search_hint));
    searchView.setIconifiedByDefault(false);
    ImageView search_mag_icon = (ImageView) searchView.findViewById(R.id.search_mag_icon);
    search_mag_icon.setImageResource(0);
    LinearLayout search_plate = (LinearLayout) searchView.findViewById(R.id.search_plate);
    search_plate.setBackgroundColor(Color.TRANSPARENT);
    searchView.setOnQueryTextListener(mQueryListener);
}
 
开发者ID:XYScience,项目名称:StopApp,代码行数:15,代码来源:AppListFragment.java

示例13: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQueryHint(getString(R.string.search_hint));
    searchView.setIconifiedByDefault(false);
    ImageView search_mag_icon = (ImageView) searchView.findViewById(R.id.search_mag_icon);
    search_mag_icon.setImageResource(0);
    LinearLayout search_plate = (LinearLayout) searchView.findViewById(R.id.search_plate);
    search_plate.setBackgroundColor(Color.TRANSPARENT);
    searchView.setOnQueryTextListener(mQueryListener);
    return true;
}
 
开发者ID:XYScience,项目名称:StopApp,代码行数:16,代码来源:MainActivity.java

示例14: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.song_sort_by, menu);
    searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.song_search));
    searchView.setOnQueryTextListener(this);
    searchView.setQueryHint("Search song");
    if (Extras.getInstance().songView()) {
        menu.findItem(R.id.grid_view).setVisible(true);
    } else {
        menu.findItem(R.id.grid_view).setVisible(false);
    }
    menu.findItem(R.id.default_folder).setVisible(false);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:15,代码来源:SongListFragment.java

示例15: onCreateOptionsMenu

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

    _searchItem = menu.findItem(R.id.action_search);
    _searchView = (SearchView) _searchItem.getActionView();

    SearchManager searchManager = (SearchManager) _context.getSystemService(SEARCH_SERVICE);
    _searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    _searchView.setQueryHint(getString(R.string.search_documents));
    if (_searchView != null) {
        _searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                if (query != null) {
                    if (isVisible())
                        search(query);
                }
                return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                if (newText != null) {
                    if (isVisible()) {
                        if (newText.equalsIgnoreCase("")) {
                            clearSearchFilter();
                        } else {
                            search(newText);
                        }
                    }
                }
                return false;
            }
        });
        _searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> {
            MenuItem item = menu.findItem(R.id.action_import);
            if (item != null) {
                item.setVisible(hasFocus);
            }
            if (!hasFocus) {
                _searchItem.collapseActionView();
            }
        });
    }
    ContextUtils cu = ContextUtils.get();

    cu.tintMenuItems(menu, true, Color.WHITE);
    cu.setSubMenuIconsVisiblity(menu, true);
}
 
开发者ID:gsantner,项目名称:markor,代码行数:52,代码来源:FilesystemListFragment.java


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