English 中文(简体)
查询后提起的诉讼
原标题:Reset action bar after using SearchView

I m using SearchView widget to enable searching in my app. After the initial click on the search icon, the SearchView widget expands into the search field and the "back" arrow is shown next to the application icon. If I click the application icon the action bar reverts to the initial state (no "back" arrow) and the SearchView reverts back to icon.

现在的问题是:在搜查完成后,行动限制会改变方向,唯一的回路是点击“icon”或“背”arrow。 并非好事,因为当搜查时,我想要行动吧进入最初状态。 我尝试了SearchView.setIconofied(true),但有两个问题:

  1. Search icon appears at the same spot as the edit field (originally it s on the far right).
  2. Action bar still displays "back" arrow.

我认为,由于偏离常规导航模式,我面临的问题一成不变。 在我的案件中,一切都发生在同一活动范围内(研究结果见于作为行动标的同一活动),例如,执行<条码>的操作性。

How do I trigger "go back one step" of the action bar? Or simulate click on the application icon?

最佳回答

It sounds like you ve set this up as a collapsible action view on a MenuItem. You can call collapseActionView() on that MenuItem instance to send it back to its closed state.

问题回答

仅从第14级改为第14级。 如果你重新寻求支持先前版本的甲状腺,那么你就应当使用图书馆。

这里,我的解决办法是,打破搜寻和重新确定行动路线......

private MenuItem searchMenuItem;

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    getMenuInflater().inflate(R.menu.main_menu, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchMenuItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);

    customizeSearchView(searchView);

    return super.onCreateOptionsMenu(menu);
}




    @Override
protected void onNewIntent(Intent intent)
{
    setIntent(intent);

    if (searchMenuItem != null)
    {
        if (MenuItemCompat.expandActionView(searchMenuItem))
        {
            MenuItemCompat.collapseActionView(searchMenuItem);
        }
        else if (MenuItemCompat.collapseActionView(searchMenuItem))
        {
            MenuItemCompat.expandActionView(searchMenuItem);
        }
    }

    handleIntent(intent);
}




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签