0

I created a Search Interface in Android. when we click on hardware search button our own search Dialog pops up. like this tutorial : http://www.edumobile.org/android/android-programming-tutorials/search-interface/

Then I made a action bar ( http://developer.android.com/resources/samples/ActionBarCompat/index.html) and I put a search button on it. I want to load my search Dialog when I click on the button.(The same when I click on hardware search button on the phone)

I appreciate for any help.

4

2 に答える 2

0

答えはあなたが与えたように秒の中にあります:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_search:
        Toast.makeText(this, "Tapped search", Toast.LENGTH_SHORT).show();
        break;
    }
}

ActionBarActivity を使用してアクションバーでアクティビティを拡張し、このメソッドをオーバーライドするだけです。

于 2012-04-05T14:16:11.020 に答える
0

メソッド onSearchRequested() を呼び出す前に成功しました。イオンが提案したこともうまくいくかもしれません。

ドキュメントを参照してください: http://developer.android.com/reference/android/app/Activity.html#onSearchRequested%28%29

于 2012-04-05T14:57:42.750 に答える