Android没有调用任何这些
searchManager.setondismissListener( new OndismissListener() { @OverrIDe public voID ondismiss() { // Todo auto-generated method stub Log.v(MyApp.TAG,"on dismiss search"); } }); searchManager.setonCancelListener( new OnCancelListener() { @OverrIDe public voID onCancel() { // Todo auto-generated method stub Log.v(MyApp.TAG,"on dismiss cancel"); } });@OverrIDe public boolean onSearchRequested() { Bundle appData = new Bundle(); appData.putLong("Listino_ID",this.Listino_ID); this.startSearch(null,true,appData,false); return true; // return super.onSearchRequested(); }
我需要我的活动不是singleOntop,
这是我的AndroIDManifest.xml
<activity androID:name=".activity.ListinoprodottiActivity" androID:windowsoftinputMode="stateHIDden"> <!-- Receives the search request. --> <intent-filter> <action androID:name="androID.intent.action.SEARCH" /> <!-- No category needed,because the Intent will specify this class component--> </intent-filter> <!-- enable the base activity to send searches to itself --> <Meta-data androID:name="androID.app.default_searchable" androID:value=".activity.ListinoprodottiActivity" /> <!-- Points to searchable Meta data. --> <Meta-data androID:name="androID.app.searchable" androID:resource="@xml/searchable" /> </activity>
这是我的searchable.xml
<?xml version="1.0" enCoding="utf-8"?><searchable xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:label="@string/app_name" />解决方法 在Search Widget中使用bundle传递数据:
layout / main.xml:
<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:orIEntation="vertical" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent"> <TextVIEw androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/hello" /> <button androID:ID="@+ID/button" androID:text="test" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" /></linearLayout>
layout / searchable.xml:
<?xml version="1.0" enCoding="utf-8"?><searchable xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:label="@string/search_label" androID:hint="@string/search_hint" androID:searchMode="showSearchLabelAsBadge" androID:voiceSearchMode="showVoiceSearchbutton|launchRecognizer" androID:voiceLanguageModel="free_form" androID:voicePromptText="@string/search_invoke" androID:searchSuggestSelection=" ? "/>
values / strings.xml:
<?xml version="1.0" enCoding="utf-8"?><resources><string name="hello">Hello World,SearchTest!</string><string name="app_name">Searchtest</string><string name="search_label">Search Test</string><string name="search_hint">1234</string><string name="search_invoke">234</string><string name="search_query_results">544545</string></resources>
AndroIDManifest.xml:
<application androID:icon="@drawable/ic_launcher" androID:label="@string/app_name" > <activity androID:label="@string/app_name" androID:name=".SearchWidgetExampleTest" > <intent-filter > <action androID:name="androID.intent.action.MAIN" /> <category androID:name="androID.intent.category.LAUNCHER" /> </intent-filter> <Meta-data androID:name="androID.app.default_searchable" androID:value=".ResultActivty" /> </activity> <activity androID:name=".ResultActivty" androID:label="@string/search_query_results"> <intent-filter> <action androID:name="androID.intent.action.MAIN" /> <category androID:name="androID.intent.category.SAMPLE_CODE" /> </intent-filter> <intent-filter> <action androID:name="androID.intent.action.SEARCH" /> <category androID:name="androID.intent.category.DEFAulT" /> </intent-filter> <Meta-data androID:name="androID.app.searchable" androID:resource="@layout/searchable" /> </activity> </application>
ResultActivty.java:
package org.imranandroID.TestSearchexmp;import androID.app.Activity;import androID.app.SearchManager;import androID.os.Bundle;import androID.Widget.Toast;public class ResultActivty extends Activity{ @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); Bundle bundled= getIntent().getBundleExtra(SearchManager.APP_DATA); Long ttdata=bundled.getLong("Listino_ID"); Toast.makeText(this,ttdata.toString(),Toast.LENGTH_SHORT).show(); }}
SearchWidgetExampleTest.java:
package org.imranandroID.TestSearchexmp;import androID.app.Activity;import androID.os.Bundle;import androID.vIEw.VIEw;import androID.vIEw.VIEw.OnClickListener;import androID.Widget.button;public class SearchWidgetExampleTest extends Activity { @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); button button1 = (button) findVIEwByID(R.ID.button); button1.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw v) { onSearchRequested(); } }); } @OverrIDe public boolean onSearchRequested() { Bundle appDataBundle = new Bundle(); appDataBundle.putLong("Listino_ID",4434724724L); startSearch("imran",false,appDataBundle,false); return true; }}
快乐编码!!!
总结以上是内存溢出为你收集整理的android传递包与搜索全部内容,希望文章能够帮你解决android传递包与搜索所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)