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


Java SearchView.setQuery方法代码示例

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


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

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
private void updateSearch(String search) {
    if (menuSearch != null) {
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch);
        if (search == null) {
            if (menuSearch.isActionViewExpanded())
                adapter.getFilter().filter(searchView.getQuery().toString());
        } else {
            MenuItemCompat.expandActionView(menuSearch);
            searchView.setQuery(search, true);
        }
    }
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:13,代码来源:ActivityMain.java

示例3: onCreate

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);

    mSearchView = (SearchView) findViewById(R.id.search_view);
    setupSearchView();
    mSearchResults = (ListView) findViewById(R.id.search_results);
    mResultsAdapter = new SimpleCursorAdapter(this,
            R.layout.list_item_search_result, null,
            new String[]{ScheduleContract.SearchTopicSessionsColumns.SEARCH_SNIPPET},
            new int[]{R.id.search_result}, 0);
    mSearchResults.setAdapter(mResultsAdapter);
    mSearchResults.setOnItemClickListener(this);
    Toolbar toolbar = getActionBarToolbar();

    Drawable up = DrawableCompat.wrap(ContextCompat.getDrawable(this, R.drawable.ic_up));
    DrawableCompat.setTint(up, getResources().getColor(R.color.app_body_text_2));
    toolbar.setNavigationIcon(up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            navigateUpOrBack(SearchActivity.this, null);
        }
    });

    String query = getIntent().getStringExtra(SearchManager.QUERY);
    query = query == null ? "" : query;
    mQuery = query;

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        doEnterAnim();
    }

    overridePendingTransition(0, 0);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:41,代码来源:SearchActivity.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

示例5: onPrepareOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (isInputMode) {
        menu.findItem(R.id.action_info).setVisible(false);
        menu.findItem(R.id.action_sort).setVisible(false);
        SearchView searchView = (SearchView) MenuItemCompat.
                getActionView(menu.findItem(R.id.action_search));
        searchView.setQuery(mPresenter.getSearchModels().get(0).getQuery(), false);
    } else {
        menu.findItem(R.id.action_info).setVisible(false);
        menu.findItem(R.id.action_sort).setVisible(pagerAdapter.getCount() != 0);
    }
    return super.onPrepareOptionsMenu(menu);
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:15,代码来源:SearchActivity.java

示例6: onCreateOptionsMenu

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

    getMenuInflater().inflate(R.menu.search_toolbar, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search)
            .getActionView();
    setupSearchView(searchView);

    if (currentQuery != null) {
        searchView.setQuery(currentQuery, false);
    }

    return true;
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:16,代码来源:SearchActivity.java

示例7: onPrepareOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onPrepareOptionsMenu(Menu menu) {
    // search view
    MenuItem searchViewMenuItem = menu.findItem(R.id.menu_search_action_search_view);
    final SearchView searchView = (SearchView) searchViewMenuItem.getActionView();
    if (searchQueryKeyword != null && !searchQueryKeyword.isEmpty()) {
        searchView.setQuery(searchQueryKeyword, false);
    }
    // sort
    MenuItem sortPackageName = menu.findItem(R.id.menu_search_action_sort_package_name);
    MenuItem sortVotes = menu.findItem(R.id.menu_search_action_sort_votes);
    MenuItem sortPopularity = menu.findItem(R.id.menu_search_action_sort_popularity);
    MenuItem sortMaintainer = menu.findItem(R.id.menu_search_action_sort_maintainer);
    MenuItem sortLastModified = menu.findItem(R.id.menu_search_action_sort_last_modified);
    MenuItem sortFirstSubmitted = menu.findItem(R.id.menu_search_action_sort_first_submitted);
    MenuItem sortLastSubmitted = menu.findItem(R.id.menu_search_action_sort_last_submitted);
    switch (searchSortOrder) {
        case SORT_ORDER_PACKAGE_NAME:
            sortPackageName.setChecked(true);
            break;
        case SORT_ORDER_VOTES:
            sortVotes.setChecked(true);
            break;
        case SORT_ORDER_POPULARITY:
            sortPopularity.setChecked(true);
            break;
        case SORT_ORDER_MAINTAINER:
            sortMaintainer.setChecked(true);
            break;
        case SORT_ORDER_LAST_MODIFIED:
            sortLastModified.setChecked(true);
            break;
        case SORT_ORDER_FIRST_SUBMITTED:
            sortFirstSubmitted.setChecked(true);
            break;
        case SORT_ORDER_LAST_SUBMITTED:
            sortLastSubmitted.setChecked(true);
            break;
        default:
            sortPackageName.setChecked(true);
            break;
    }
    // search field
    MenuItem searchNameDescription = menu.findItem(R.id.menu_search_action_search_by_name_and_description);
    MenuItem searchPackageName = menu.findItem(R.id.menu_search_action_search_by_package_name);
    MenuItem searchMaintainer = menu.findItem(R.id.menu_search_action_search_by_maintainer);
    switch (searchQuerySearchBy) {
        case SEARCH_BY_NAME_DESCRIPTION:
            searchNameDescription.setChecked(true);
            break;
        case SEARCH_BY_PACKAGE_NAME:
            searchPackageName.setChecked(true);
            break;
        case SEARCH_BY_MAINTAINER:
            searchMaintainer.setChecked(true);
            break;
    }
    super.onPrepareOptionsMenu(menu);
}
 
开发者ID:rascarlo,项目名称:AURdroid,代码行数:60,代码来源:SearchFragment.java


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