Java Code Examples for androidx.appcompat.widget.SearchView#setSubmitButtonEnabled()

The following examples show how to use androidx.appcompat.widget.SearchView#setSubmitButtonEnabled() . 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: ConversationActivity.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    showActionBar();
    //return false;
    getMenuInflater().inflate(R.menu.mobicom_basic_menu_for_normal_message, menu);
    MenuItem searchItem = menu.findItem(R.id.menu_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getResources().getString(R.string.search_hint));
    if (Utils.hasICS()) {
        searchItem.collapseActionView();
    }
    searchView.setOnQueryTextListener(this);
    searchView.setSubmitButtonEnabled(true);
    searchView.setIconifiedByDefault(true);

    if (quickConversationFragment != null && !TextUtils.isEmpty(quickConversationFragment.getSearchString())) {
        searchView.setIconified(false);
        searchView.setQuery(quickConversationFragment.getSearchString(), false);
    }

    return super.onCreateOptionsMenu(menu);
}
 
Example 2
Source File: SearchActivity.java    From WanAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_search, menu);
    MenuItem menuItem = menu.findItem(R.id.item_search);
    //得到SearchView
    mSearchView = (SearchView)menuItem.getActionView();
    mSearchAutoComplete = mSearchView.findViewById(R.id.search_src_text);
    mSearchView.setMaxWidth(R.dimen.dp_400);//设置最大宽度
    mSearchView.setSubmitButtonEnabled(true);//设置是否显示搜索框展开时的提交按钮
    mSearchView.setQueryHint(getResources().getString(R.string.searchActivity_hint));//设置输入框提示语
    mSearchView.onActionViewExpanded();//设置搜索框直接展开显示。左侧有放大镜(在搜索框中) 右侧无叉叉 有输入内容后有叉叉 不能关闭搜索框
    mSearchAutoComplete.setTextColor(getResources().getColor(R.color.white));//设置内容文字颜色
    //搜索框文字变化监听,搜索按钮监听
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            mPresenter.addHistoryRecord(query);
            mPresenter.loadSearchResquest(query, 0);
            isLoadMore = false;
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mPresenter.clearAllSearchKey(newText);
            return false;
        }
    });
    return super.onCreateOptionsMenu(menu);
}
 
Example 3
Source File: MobiComKitPeopleActivity.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_contact, menu);
    MenuItem searchItem = menu.findItem(R.id.menu_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getResources().getString(R.string.search_hint));
    if (Utils.hasICS()) {
        searchItem.collapseActionView();
    }
    searchView.setOnQueryTextListener(this);
    searchView.setSubmitButtonEnabled(true);
    searchView.setIconified(true);
    return super.onCreateOptionsMenu(menu);
}
 
Example 4
Source File: SelectFileActivity.java    From turbo-editor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_select_file, menu);
    mSearchViewMenuItem = menu.findItem(R.id.im_search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchViewMenuItem);
    mSearchView.setIconifiedByDefault(true);
    mSearchView.setOnQueryTextListener(this);
    mSearchView.setSubmitButtonEnabled(false);
    return super.onCreateOptionsMenu(menu);
}