當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。