2011-08-16 27 views
4

私はアンドロイドガイドで指定されたチュートリアルを使用し、デバイスやメニュー項目の検索ボタンを押した後もすべてが必要であることを確認しました。検索ダイアログが表示されません。 私はここにhttp://developer.android.com/guide/topics/search/search-dialog.htmlアンドロイド検索ダイアログが機能しない

からチュートリアルを得たあなたたちはそれを調べて、可能な場合ので、私は私が間違っているつもりだどこ知ることができる助けることができるので、私はここに私のサンプルコードを掲示しなければなりません。ダイアログが結果に

public class Search extends ListActivity { 

    private Vector<?> loadedArticles; 

    @Override 
    protected void onCreate(Bundle icicle) { 
     super.onCreate(icicle); 

     setContentView(R.layout.articles); 
     Intent intent = getIntent(); 
     String query=""; 
     if (Intent.ACTION_SEARCH.equals(intent.getAction())) { 
      query = intent.getStringExtra(SearchManager.QUERY); 
     } 

     boolean articlesLoaded = findArticles(query); // it shows results and renders it. 

    } 
} 
を示し検索

<activity android:name=".Search" android:label="Search"> 
      <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="@xml/searchable"/> 
     </activity> 

用解像度での私の検索可能なファイルを、結果を返します

<activity android:name=".testAndroid" 
        android:theme="@android:style/Theme.NoTitleBar"> 
        <meta-data android:name="android.app.default_searchable" 
        android:value="com.tester.android.Search" /> 
     </activity> 

活動/ XMLフォルダ

<?xml version="1.0" encoding="utf-8"?> 
<searchable xmlns:android="http://schemas.android.com/apk/res/android" 
    android:label="XYZ.com" 
    android:hint="Search XYZ.com" > 
</searchable> 

活動を現れるべき 活動

誰かが私を助けてくれますか?ハードウェアの検索ボタンを押した後に検索ダイアログが表示されないのはなぜですか?

+0

あなたは簡単にそれを行うことができます。ここの答えを参照してください:https://stackoverflow.com/a/44131089/3649347 – GeekOnJava

答えて

12

は最後に、私自身は、私が直接文字列としてlablelとヒントを使用していた問題ここで

<searchable xmlns:android="http://schemas.android.com/apk/res/android" 
    android:label="XYZ.com" 
    android:hint="Search XYZ.com" > 
</searchable> 

への解決策を見つけました。代わりに、@ string/labelを使用する必要があります。 私たちの文字列はstrings.xmlにあるはずです。 これはAndroidのバグです。

+0

私はまだ問題が発生しています – paiego

+0

ありがとう.. Pfffff .. – eento

関連する問題