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


Java SearchView.setOnQueryTextListener方法代码示例

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


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

示例1: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    /*简单查询*/
    final MenuItem item = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(item);

    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            paraMap.put("keyWord", query);
            showLoading();
            refresh = true;
            presenter.getData(1, SIZE, paraMap);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {

            return false;
        }
    });
    return true;
}
 
开发者ID:liuyongfeng90,项目名称:JKCloud,代码行数:26,代码来源:OpportunityListActivity.java

示例2: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if(loaderId == DELETED_LOADER_ID){
        inflater.inflate(R.menu.menu_fragment_bin, menu);
    }

    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(R.drawable.ic_search_white_24dp);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM|MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    searchView = new SearchView(myActivity);
    searchView.setMaxWidth(Integer.MAX_VALUE);

    // Set searchbox text to white
    EditText searchEditText = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    searchEditText.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
    searchEditText.setHintTextColor(ContextCompat.getColor(getContext(), R.color.white));

    searchView.setOnQueryTextListener(this);
    item.setActionView(searchView);
    super.onCreateOptionsMenu(menu, inflater);

}
 
开发者ID:danlls,项目名称:Todule-android,代码行数:25,代码来源:ToduleListFragment.java

示例3: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    /*简单查询*/
    final MenuItem item = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(item);

    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            Intent intent = new Intent("Msg_KeyWord");
            intent.putExtra("keyWord", query);
            sendBroadcast(intent);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {

            return false;
        }
    });
    return true;
}
 
开发者ID:liuyongfeng90,项目名称:JKCloud,代码行数:25,代码来源:SystemReportActivity.java

示例4: onPrepareOptionsMenu

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

  boolean res = super.onPrepareOptionsMenu(menu);

  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

  searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      getWebViewCoordinator().onQueryByText(query);
      return true;
    }

    @Override
    public boolean onQueryTextChange(String newText) {
      return false;
    }
  });

  return res;
}
 
开发者ID:azmedien,项目名称:kolibri-android,代码行数:24,代码来源:PrototypeActivity.java

示例5: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main_menu, menu);
    MenuItem search = menu.findItem(R.id.search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(search);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override public boolean onQueryTextSubmit(String query) {
            getSupportActionBar().setSubtitle("found: "+mAdapter.getItemCount());
            return true;
        }
        @Override public boolean onQueryTextChange(String newText) {
            if (mAdapter != null) {
                mAdapter.getFilter().filter(newText);
            }
            return true;
        }
    });
    menu.findItem(R.id.action_settings).setIntent(new Intent(this,SettingsActivity.class));
    return true;
}
 
开发者ID:AlexeyZatsepin,项目名称:CP-Tester,代码行数:21,代码来源:MainActivity.java

示例6: setupSearchView

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
private void setupSearchView(SearchView searchView) {
    searchView.setIconifiedByDefault(false);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    if (searchManager != null) {
        SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
        searchView.setSearchableInfo(searchableInfo);
    }

    searchView.setOnQueryTextListener(this);
    searchView.requestFocus();

    searchView.setMaxWidth(Integer.MAX_VALUE);
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:15,代码来源:SearchActivity.java

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

示例8: 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.toolbar_default_menu_filechooser, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchMenuItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView)mSearchMenuItem.getActionView();
    // Assumes current activity is the searchable activity
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    //searchView.setSubmitButtonEnabled(true);
    mSearchView.setOnQueryTextListener(this);
    return true;
}
 
开发者ID:adityak368,项目名称:Android-FileBrowser-FilePicker,代码行数:16,代码来源:FileChooser.java

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

示例10: onCreateOptionsMenu

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

    getMenuInflater().inflate(R.menu.menu_activity_home, menu);

    //init search in the toolbar
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    //listener for click in search button
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            startActivity(new Intent(HomeActivity.this, SearchActivity.class)
                    .putExtra(AppConstants.General.SEARCH_TEXT, query));
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });

    return true;
}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:28,代码来源:HomeActivity.java

示例11: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@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);
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:11,代码来源:SelectFileActivity.java

示例12: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.contacts_picker_menu, menu);

    SearchView searchView = (SearchView) menu.findItem(R.id.contacts_search).getActionView();
    searchView.setOnQueryTextListener(this);

    return true;
}
 
开发者ID:gvinciguerra,项目名称:custode,代码行数:11,代码来源:ContactsPickerActivity.java

示例13: onCreate

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    mTagFlowLayout = (TagFlowLayout) findViewById(R.id.tag_flow_layout);
    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    mHintText = (TextView) findViewById(R.id.hint_text);
    mTagLayout = (LinearLayout) findViewById(R.id.tag_layout);
    mFragmentContainer = (FrameLayout) findViewById(R.id.fragment_container);
    mSearchView = (SearchView) findViewById(R.id.search_view);
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            mFragmentContainer.setVisibility(View.GONE);
            searchData(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    mExitButton = (Button) findViewById(R.id.exit_button);
    mExitButton.setOnClickListener(this);
    mFragmentManager = getSupportFragmentManager();
    loadData();
}
 
开发者ID:KnowledgeBegger,项目名称:MyEyepetizer,代码行数:29,代码来源:SearchActivity.java

示例14: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.search_menu, menu);
    MenuItem search = menu.findItem(R.id.search_menu);
    searchView = (SearchView) MenuItemCompat.getActionView(search);
    searchView.onActionViewExpanded();
    searchView.setOnQueryTextListener(this);
    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:htqqdd,项目名称:music_player,代码行数:10,代码来源:searchActivity.java

示例15: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(@NonNull final Menu menu)
{
	// inflate the menu; this adds items to the action bar if it is present.
	getMenuInflater().inflate(R.menu.main, menu);

	// search view
	final MenuItem searchMenuItem = menu.findItem(R.id.action_search);
	final SearchView searchView = (SearchView) searchMenuItem.getActionView();
	searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener()
	{
		@Override
		public boolean onQueryTextSubmit(final String query)
		{
			searchView.clearFocus();
			searchView.setQuery("", false);
			tryStartTreebolic(query);
			return true;
		}

		@Override
		public boolean onQueryTextChange(final String newText)
		{
			return false;
		}
	});

	return true;
}
 
开发者ID:1313ou,项目名称:Treebolic,代码行数:30,代码来源:MainActivity.java


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