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


Java SearchView.setInputType方法代碼示例

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


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

示例1: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.fragment_courses, menu);
    MenuItem item = menu.findItem(R.id.action_courses_search);
    SearchView searchView = (SearchView) item.getActionView();
    searchView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    searchView.setOnQueryTextListener(this);
    if (!"".equals(lastQuery)) {
        searchView.setQuery(lastQuery, false);
        item.expandActionView();
    }
}
 
開發者ID:whirlwind-studios,項目名稱:School1-Android,代碼行數:13,代碼來源:CoursesFragment.java

示例2: onCreateOptionsMenu

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

    inflater.inflate(R.menu.menu_search_view, menu);
    MenuItem menuItem = menu.findItem(R.id.action_search);

    mSearchView = (SearchView) menuItem.getActionView();
    mSearchView.setInputType(InputType.TYPE_CLASS_NUMBER);
    mSearchView.setQueryHint(getString(R.string.fragment_search_search_view_hint));
    mSearchView.setOnQueryTextListener(this);
}
 
開發者ID:joshvocal,項目名稱:TransLinkMe-App,代碼行數:13,代碼來源:SearchFragment.java

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

示例4: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_search, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView =
            (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setOnQueryTextListener(this);
    searchView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    searchView.setQuery(mPresenter.getSearchModels().get(0).getQuery(), false);
    if (isInputMode) {
        MenuItemCompat.expandActionView(searchItem);
    } else {
        MenuItemCompat.collapseActionView(searchItem);
    }
    MenuItemCompat.setOnActionExpandListener(searchItem, this);

    AutoCompleteTextView autoCompleteTextView = searchView
            .findViewById(android.support.v7.appcompat.R.id.search_src_text);
    autoCompleteTextView.setThreshold(0);
    autoCompleteTextView.setAdapter(new ArrayAdapter<>(this,
            R.layout.layout_item_simple_list, mPresenter.getSearchRecordList()));
    autoCompleteTextView.setDropDownBackgroundDrawable(new ColorDrawable(ViewUtils.getWindowBackground(getActivity())));
    autoCompleteTextView.setOnItemClickListener((parent, view, position, id) -> {
        onQueryTextSubmit(parent.getAdapter().getItem(position).toString());
    });

    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:ThirtyDegreesRay,項目名稱:OpenHub,代碼行數:29,代碼來源:SearchActivity.java


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