Android中Creating a Searchable Activity

2014-11-24 13:00:13 · 作者: · 浏览: 2

1.在中用ACTION SEARCH声明这个Activity。


2.用来指定searchable configuration。


例如:


执行查询:


当你的activity启动时,通过下面的代码来获得查询:


public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);


// Get the intent, verify the action and get the query
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
doMySearch(query);
}
}


doMySearch(query)是你自己的函数,用来完成查询的具体工作。