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


Java OnQueryTextListener类代码示例

本文整理汇总了Java中com.actionbarsherlock.widget.SearchView.OnQueryTextListener的典型用法代码示例。如果您正苦于以下问题:Java OnQueryTextListener类的具体用法?Java OnQueryTextListener怎么用?Java OnQueryTextListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onCreateOptionsMenu

import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	getSupportMenuInflater().inflate(R.menu.main, menu);
	final MenuItem searchMenuItem = menu.findItem(R.id.search);
	SearchView searchView = (SearchView) searchMenuItem.getActionView();
	searchView.setOnQueryTextListener(new OnQueryTextListener() {

		@Override
		public boolean onQueryTextSubmit(String query) {
			searchMenuItem.collapseActionView();
			showSearchFragment(query);
			return true;
		}

		@Override
		public boolean onQueryTextChange(String newText) {
			return false;
		}
	});
	return true;
}
 
开发者ID:MoshDev,项目名称:TwitterFeedReaderSample,代码行数:22,代码来源:MainActivity.java

示例2: onPrepareOptionsMenu

import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public void onPrepareOptionsMenu(Menu menu) {
	if(Build.VERSION.SDK_INT >= 8) {
		SearchView searchView = new SearchView(getSherlockActivity().getSupportActionBar().getThemedContext());
	    searchView.setQueryHint("Buscar paradas…");
	    searchView.setIconified(true);
	    searchView.setOnQueryTextListener(new OnQueryTextListener() {
			
			@Override
			public boolean onQueryTextSubmit(String query) {
				buscarParadas(query.toString());
				return false;
			}
			
			@Override
			public boolean onQueryTextChange(String newText) {
				buscarParadas(newText);
				return false;
			}
		});
		MenuItem buscar = menu.findItem(R.id.buscar);
		buscar.setVisible(true);
		buscar.setActionView(searchView);
	}
	super.onPrepareOptionsMenu(menu);
}
 
开发者ID:Arasthel,项目名称:AlmeriBus,代码行数:27,代码来源:MostrarListadosParadasFragment.java

示例3: onCreateOptionsMenu

import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Search view
    getSupportMenuInflater().inflate(R.menu.search, menu);
    // Settings
    getSupportMenuInflater().inflate(R.menu.activity_base, menu);
    // Theme the search icon
    mResources.setSearchIcon(menu);

    final SearchView searchView = (SearchView)menu.findItem(R.id.menu_search).getActionView();
    // Add voice search
    final SearchManager searchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
    final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
    searchView.setSearchableInfo(searchableInfo);
    // Perform the search
    searchView.setOnQueryTextListener(new OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(final String query) {
            // Open the search activity
            NavUtils.openSearch(BaseActivity.this, query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(final String newText) {
            // Nothing to do
            return false;
        }
    });
    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:36,代码来源:BaseActivity.java

示例4: onCreateOptionsMenu

import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Search view
    getSupportMenuInflater().inflate(R.menu.search, menu);
    // Theme the search icon
    mResources.setSearchIcon(menu);

    final SearchView searchView = (SearchView)menu.findItem(R.id.menu_search).getActionView();
    // Add voice search
    final SearchManager searchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
    final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
    searchView.setSearchableInfo(searchableInfo);
    // Perform the search
    searchView.setOnQueryTextListener(new OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(final String query) {
            // Open the search activity
            NavUtils.openSearch(AudioPlayerActivity.this, query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(final String newText) {
            // Nothing to do
            return false;
        }
    });

    // Favorite action
    getSupportMenuInflater().inflate(R.menu.favorite, menu);
    // Shuffle all
    getSupportMenuInflater().inflate(R.menu.shuffle, menu);
    // Share, ringtone, and equalizer
    getSupportMenuInflater().inflate(R.menu.audio_player, menu);
    // Settings
    getSupportMenuInflater().inflate(R.menu.activity_base, menu);
    return true;
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:43,代码来源:AudioPlayerActivity.java

示例5: onCreateOptionsMenu

import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
	final SherlockFragmentActivity activity = (SherlockFragmentActivity) getActivity();
	final SearchView searchView = new SearchView(activity
			.getSupportActionBar().getThemedContext());
	searchView.setQueryHint(getString(R.string.search));
	final int searchId = 1337;
	menu.add(Menu.NONE, searchId, 1, getString(R.string.search))
			.setIcon(R.drawable.abs__ic_search)
			.setActionView(searchView)
			.setShowAsAction(
					MenuItem.SHOW_AS_ACTION_ALWAYS
							| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
	searchView.setOnQueryTextListener(new OnQueryTextListener() {
		@Override
		public boolean onQueryTextChange(final String newText) {
			return false;
		}

		@Override
		public boolean onQueryTextSubmit(final String query) {
			searchTerms = query;
			search();
			// Hide keyboard
			final InputMethodManager imm = (InputMethodManager) activity
					.getSystemService(Context.INPUT_METHOD_SERVICE);
			imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
			// Hide searchView

			menu.findItem(searchId).collapseActionView();
			return false;
		}
	});
	super.onCreateOptionsMenu(menu, inflater);
}
 
开发者ID:razielsarafan,项目名称:lastfm-for-android,代码行数:36,代码来源:SearchFragment.java


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