Java Code Examples for android.support.v4.view.MenuItemCompat#expandActionView()

The following examples show how to use android.support.v4.view.MenuItemCompat#expandActionView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchActivity.java    From fangzhuishushenqi with Apache License 2.0 5 votes vote down vote up
/**
 * 展开SearchView进行查询
 *
 * @param key
 */
private void search(String key) {
    MenuItemCompat.expandActionView(searchMenuItem);
    if (!TextUtils.isEmpty(key)) {
        searchView.setQuery(key, true);
        saveSearchHistory(key);
    }
}
 
Example 2
Source File: JournalFragment.java    From BlackList with Apache License 2.0 5 votes vote down vote up
private void searchItems(String query) {
    if (itemSearch != null && searchView != null) {
        MenuItemCompat.expandActionView(itemSearch);
        searchView.setQuery(query, true);
        searchView.clearFocus();
    }
}
 
Example 3
Source File: SearchActivity.java    From OpenHub with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: UserFragment.java    From droidddle with Apache License 2.0 5 votes vote down vote up
private void startMenuLoading() {
    if (mMenuProgressView == null) {
        initMenuProgressView();
    }
    MenuItemCompat.setActionView(mFollowMenu, R.layout.menu_item_action_refresh);
    MenuItemCompat.expandActionView(mFollowMenu);
    View view = MenuItemCompat.getActionView(mFollowMenu);
    ((ProgressView) view.findViewById(R.id.progress)).start();
}
 
Example 5
Source File: SearchActivity.java    From BookReader with Apache License 2.0 5 votes vote down vote up
/**
 * 展开SearchView进行查询
 *
 * @param key
 */
private void search(String key) {
    MenuItemCompat.expandActionView(searchMenuItem);
    if (!TextUtils.isEmpty(key)) {
        searchView.setQuery(key, true);
        saveSearchHistory(key);
    }
}
 
Example 6
Source File: BuildpropFragment.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.search:
            MenuItemCompat.expandActionView(searchItem);
            break;
    }
    return true;
}
 
Example 7
Source File: SearchBook.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
    getMenuInflater().inflate(R.menu.menu_searchbook, menu);
    menuItemSearch = menu.findItem(R.id.search_button);
    searchView = (SearchView) MenuItemCompat.getActionView(menuItemSearch);
    searchView.setQueryHint(getString(R.string.hint_searchbook));
    searchView.setSubmitButtonEnabled(true);
    searchView.setOnQueryTextListener(oQueryTextListener);
    ImageView mSearchHintIcon = (ImageView) searchView.findViewById(R.id.search_mag_icon);
    mSearchHintIcon.setVisibility(View.GONE);
    MenuItemCompat.expandActionView(menuItemSearch);
    return true;
}
 
Example 8
Source File: TeamFragment.java    From droidddle with Apache License 2.0 4 votes vote down vote up
private void startMenuLoading() {
    MenuItemCompat.setActionView(mFollowMenu, R.layout.menu_item_action_refresh);
    MenuItemCompat.expandActionView(mFollowMenu);
    View view = MenuItemCompat.getActionView(mFollowMenu);
    ((ProgressView) view.findViewById(R.id.progress)).start();
}
 
Example 9
Source File: ActivityMain.java    From Clip-Stack with MIT License 4 votes vote down vote up
@Override
public boolean onSearchRequested() {
    MenuItemCompat.expandActionView(searchItem);
    searchView.requestFocus();
    return true;
}