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


Java SearchViewCompat类代码示例

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


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

示例1: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    SherlockFragmentActivity activity = (SherlockFragmentActivity)getActivity();
    View searchView = SearchViewCompat.newSearchView(activity.getSupportActionBar().getThemedContext());
    if (searchView != null) {
        SearchViewCompat.setOnQueryTextListener(searchView,
                new OnQueryTextListenerCompat() {
            @Override
            public boolean onQueryTextChange(String newText) {
                // Called when the action bar search text has changed.  Update
                // the search filter, and restart the loader to do a new query
                // with this filter.
                mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
                getLoaderManager().restartLoader(0, null, CursorLoaderListFragment.this);
                return true;
            }
        });
        item.setActionView(searchView);
    }
}
 
开发者ID:Mobideck,项目名称:appdeck-android,代码行数:24,代码来源:LoaderCursorSupport.java

示例2: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    View searchView = SearchViewCompat.newSearchView(getActivity());
    if (searchView != null) {
        SearchViewCompat.setOnQueryTextListener(searchView,
                new OnQueryTextListenerCompat() {
            @Override
            public boolean onQueryTextChange(String newText) {
                // Called when the action bar search text has changed.  Since this
                // is a simple array adapter, we can just have it do the filtering.
                mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
                mAdapter.getFilter().filter(mCurFilter);
                return true;
            }
        });
        item.setActionView(searchView);
    }
}
 
开发者ID:Mobideck,项目名称:appdeck-android,代码行数:22,代码来源:LoaderCustomSupport.java

示例3: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    View searchView = SearchViewCompat.newSearchView(getActivity());
    if (searchView != null) {
        SearchViewCompat.setOnQueryTextListener(searchView,
                new OnQueryTextListenerCompat() {
            @Override
            public boolean onQueryTextChange(String newText) {
                // Called when the action bar search text has changed.  Update
                // the search filter, and restart the loader to do a new query
                // with this filter.
                mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
                getLoaderManager().restartLoader(0, null, CursorLoaderListFragment.this);
                return true;
            }
        });
        item.setActionView(searchView);
    }
}
 
开发者ID:shakalaca,项目名称:learning_gradle_android,代码行数:23,代码来源:LoaderCursorSupport.java

示例4: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(android.R.drawable.ic_menu_search);
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS
            | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    View searchView = SearchViewCompat.newSearchView(getActivity());
    if (searchView != null) {
        SearchViewCompat.setOnQueryTextListener(searchView,
                new OnQueryTextListenerCompat() {
            @Override
            public boolean onQueryTextChange(String newText) {
                // Called when the action bar search text has changed.  Update
                // the search filter, and restart the loader to do a new query
                // with this filter.
                String newFilter = !TextUtils.isEmpty(newText) ? newText : null;
                // Don't do anything if the filter hasn't actually changed.
                // Prevents restarting the loader when restoring state.
                if (mCurFilter == null && newFilter == null) {
                    return true;
                }
                if (mCurFilter != null && mCurFilter.equals(newFilter)) {
                    return true;
                }
                mCurFilter = newFilter;
                getLoaderManager().restartLoader(0, null, CursorLoaderListFragment.this);
                return true;
            }
        });
        MenuItemCompat.setActionView(item, searchView);
    }
}
 
开发者ID:reknih,项目名称:informant-droid,代码行数:33,代码来源:LoaderRetainedSupport.java

示例5: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(android.R.drawable.ic_menu_search);
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM
            | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    final View searchView = SearchViewCompat.newSearchView(getActivity());
    if (searchView != null) {
        SearchViewCompat.setOnQueryTextListener(searchView,
                new OnQueryTextListenerCompat() {
            @Override
            public boolean onQueryTextChange(String newText) {
                // Called when the action bar search text has changed.  Since this
                // is a simple array adapter, we can just have it do the filtering.
                mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
                mAdapter.getFilter().filter(mCurFilter);
                return true;
            }
        });
        SearchViewCompat.setOnCloseListener(searchView,
                new OnCloseListenerCompat() {
                    @Override
                    public boolean onClose() {
                        if (!TextUtils.isEmpty(SearchViewCompat.getQuery(searchView))) {
                            SearchViewCompat.setQuery(searchView, null, true);
                        }
                        return true;
                    }
            
        });
        MenuItemCompat.setActionView(item, searchView);
    }
}
 
开发者ID:reknih,项目名称:informant-droid,代码行数:34,代码来源:LoaderCustomSupport.java

示例6: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.actions, menu);
    View searchView = MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
    SearchViewCompat.setOnQueryTextListener(searchView, mOnQueryTextListener);
    return true;
}
 
开发者ID:reknih,项目名称:informant-droid,代码行数:9,代码来源:ActionBarUsage.java

示例7: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.contact_list_menu, menu);
    
    mSearchView = SearchViewCompat.newSearchView(this);
    
    if (mSearchView != null)
    {
        MenuItem item = menu.add("Search")
                .setIcon(android.R.drawable.ic_menu_search)
                .setActionView(mSearchView);
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

        SearchViewCompat.setOnQueryTextListener(mSearchView, new SearchViewCompat.OnQueryTextListenerCompat() {

            @Override
            public boolean onQueryTextChange(String newText) {
                mFilterView.doFilter(newText);
                return true;
            }

            @Override
            public boolean onQueryTextSubmit(String query) {
                mFilterView.doFilter(query);
                return true;
            }
            
            
        });
    
        
    }

    return true;
}
 
开发者ID:prive,项目名称:prive-android,代码行数:37,代码来源:ContactListActivity.java

示例8: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

	// 客户列表菜单
	inflater.inflate(R.menu.transnode_list, menu);

	// 获取“搜索按钮”菜单控件
	MenuItem item = menu.findItem(R.id.action_search);
	final SearchView searchView = (SearchView) item.getActionView();
	if (searchView != null) {

		SearchViewCompat.setOnQueryTextListener(searchView,
				new OnQueryTextListenerCompat() {
					@Override
					public boolean onQueryTextChange(String newText) {

						return true;
					}

					// 当搜索结果提交时执行
					@Override
					public boolean onQueryTextSubmit(String query) {
						if (!TextUtils.isEmpty(query)) {
							RefreshList(query);
							SearchViewCompat.setQuery(searchView, null,
									true);
						}
						return true;
					}
				});
		SearchViewCompat.setOnCloseListener(searchView,
				new OnCloseListenerCompat() {
					@Override
					public boolean onClose() {
						if (!TextUtils.isEmpty(SearchViewCompat
								.getQuery(searchView))) {
							SearchViewCompat.setQuery(searchView, null,
									true);
						}
						return true;
					}

				});
		MenuItemCompat.setActionView(item, searchView);
	}
}
 
开发者ID:Extrace,项目名称:Extrace_UserApp,代码行数:47,代码来源:TransNodeListActivity.java

示例9: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

	// 客户列表菜单
	inflater.inflate(R.menu.customer_list, menu);

	// 获取“搜索按钮”菜单控件
	MenuItem item = menu.findItem(R.id.action_search);
	final SearchView searchView = (SearchView) item.getActionView();
	if (searchView != null) {

		SearchViewCompat.setOnQueryTextListener(searchView,
				new OnQueryTextListenerCompat() {
					@Override
					public boolean onQueryTextChange(String newText) {

						return true;
					}

					// 当搜索结果提交时执行
					@Override
					public boolean onQueryTextSubmit(String query) {
						if (!TextUtils.isEmpty(query)) {
							RefreshList(query);
							SearchViewCompat.setQuery(searchView, null,
									true);
						}
						return true;
					}
				});
		SearchViewCompat.setOnCloseListener(searchView,
				new OnCloseListenerCompat() {
					@Override
					public boolean onClose() {
						if (!TextUtils.isEmpty(SearchViewCompat
								.getQuery(searchView))) {
							SearchViewCompat.setQuery(searchView, null,
									true);
						}
						return true;
					}

				});
		MenuItemCompat.setActionView(item, searchView);
	}
}
 
开发者ID:Extrace,项目名称:Extrace_UserApp,代码行数:47,代码来源:CustomerListActivity.java

示例10: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	// TODO Auto-generated method stub
	MenuItem search = menu.findItem(R.id.action_search);
	final SearchView searchView = (SearchView) search.getActionView();
	searchView.setQueryHint("网点名称,区域码...");
	if (searchView != null) {

		SearchViewCompat.setOnQueryTextListener(searchView,
				new OnQueryTextListenerCompat() {
					@Override
					public boolean onQueryTextChange(String newText) {

						return true;
					}

					// 当搜索结果提交时执行
					@Override
					public boolean onQueryTextSubmit(String query) {
						if (!TextUtils.isEmpty(query)) {
							loadNodesLatlng(query);
							SearchViewCompat.setQuery(searchView, null,
									true);
						}
						return true;
					}
				});
		SearchViewCompat.setOnCloseListener(searchView,
				new OnCloseListenerCompat() {
					@Override
					public boolean onClose() {
						if (!TextUtils.isEmpty(SearchViewCompat
								.getQuery(searchView))) {
							SearchViewCompat.setQuery(searchView, null,
									true);
						}
						return true;
					}

				});
		MenuItemCompat.setActionView(search, searchView);
	}
	super.onCreateOptionsMenu(menu, inflater);
}
 
开发者ID:Extrace,项目名称:Extrace_UserApp,代码行数:45,代码来源:TransNodeTabFragment.java

示例11: onCreateOptionsMenu

import android.support.v4.widget.SearchViewCompat; //导入依赖的package包/类
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(android.R.drawable.ic_menu_search);
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS
            | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    final View searchView = SearchViewCompat.newSearchView(getActivity());
    if (searchView != null) {
        SearchViewCompat.setOnQueryTextListener(searchView,
                new OnQueryTextListenerCompat() {
            @Override
            public boolean onQueryTextChange(String newText) {
                // Called when the action bar search text has changed.  Update
                // the search filter, and restart the loader to do a new query
                // with this filter.
                String newFilter = !TextUtils.isEmpty(newText) ? newText : null;
                // Don't do anything if the filter hasn't actually changed.
                // Prevents restarting the loader when restoring state.
                if (mCurFilter == null && newFilter == null) {
                    return true;
                }
                if (mCurFilter != null && mCurFilter.equals(newFilter)) {
                    return true;
                }
                mCurFilter = newFilter;
                getLoaderManager().restartLoader(0, null, CursorLoaderListFragment.this);
                return true;
            }
        });
        SearchViewCompat.setOnCloseListener(searchView,
                new OnCloseListenerCompat() {
                    @Override
                    public boolean onClose() {
                        if (!TextUtils.isEmpty(SearchViewCompat.getQuery(searchView))) {
                            SearchViewCompat.setQuery(searchView, null, true);
                        }
                        return true;
                    }
            
        });
        MenuItemCompat.setActionView(item, searchView);
    }
}
 
开发者ID:reknih,项目名称:informant-droid,代码行数:44,代码来源:LoaderCursorSupport.java


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