當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuItemCompat.expandActionView方法代碼示例

本文整理匯總了Java中android.support.v4.view.MenuItemCompat.expandActionView方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItemCompat.expandActionView方法的具體用法?Java MenuItemCompat.expandActionView怎麽用?Java MenuItemCompat.expandActionView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.view.MenuItemCompat的用法示例。


在下文中一共展示了MenuItemCompat.expandActionView方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: restoreActionViewStates

import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
public void restoreActionViewStates(Bundle states) {
    if (states != null) {
        SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(getActionViewStatesKey());
        int itemCount = size();
        for (int i = 0; i < itemCount; i++) {
            MenuItem item = getItem(i);
            View v = MenuItemCompat.getActionView(item);
            if (!(v == null || v.getId() == -1)) {
                v.restoreHierarchyState(viewStates);
            }
            if (item.hasSubMenu()) {
                ((SubMenuBuilder) item.getSubMenu()).restoreActionViewStates(states);
            }
        }
        int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
        if (expandedId > 0) {
            MenuItem itemToExpand = findItem(expandedId);
            if (itemToExpand != null) {
                MenuItemCompat.expandActionView(itemToExpand);
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:24,代碼來源:MenuBuilder.java

示例2: onOptionsItemSelected

import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
/**
 * Handles selected item from action bar
 *
 * @param item - item
 * @return
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    if (id == R.id.action_search) {
        MenuItemCompat.expandActionView(item);
        return true;
    }

    return super.onOptionsItemSelected(item);

}
 
開發者ID:pawelpaszki,項目名稱:youtube_background_android,代碼行數:22,代碼來源:MainActivity.java

示例3: search

import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
/**
 * 展開SearchView進行查詢
 *
 * @param key
 */
private void search(String key) {
    MenuItemCompat.expandActionView(searchMenuItem);
    if (!TextUtils.isEmpty(key)) {
        searchView.setQuery(key, true);
        saveSearchHistory(key);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:SearchActivity.java

示例4: updateSearch

import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
private void updateSearch(String search) {
    if (menuSearch != null) {
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch);
        if (search == null) {
            if (menuSearch.isActionViewExpanded())
                adapter.getFilter().filter(searchView.getQuery().toString());
        } else {
            MenuItemCompat.expandActionView(menuSearch);
            searchView.setQuery(search, true);
        }
    }
}
 
開發者ID:miankai,項目名稱:MKAPP,代碼行數:13,代碼來源:ActivityMain.java

示例5: searchItems

import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
private void searchItems(String query) {
    if (itemSearch != null && searchView != null) {
        MenuItemCompat.expandActionView(itemSearch);
        searchView.setQuery(query, true);
        searchView.clearFocus();
    }
}
 
開發者ID:kaliturin,項目名稱:BlackList,代碼行數:8,代碼來源:JournalFragment.java

示例6: onCreateOptionsMenu

import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_search, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView =
            (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setOnQueryTextListener(this);
    searchView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    searchView.setQuery(mPresenter.getSearchModels().get(0).getQuery(), false);
    if (isInputMode) {
        MenuItemCompat.expandActionView(searchItem);
    } else {
        MenuItemCompat.collapseActionView(searchItem);
    }
    MenuItemCompat.setOnActionExpandListener(searchItem, this);

    AutoCompleteTextView autoCompleteTextView = searchView
            .findViewById(android.support.v7.appcompat.R.id.search_src_text);
    autoCompleteTextView.setThreshold(0);
    autoCompleteTextView.setAdapter(new ArrayAdapter<>(this,
            R.layout.layout_item_simple_list, mPresenter.getSearchRecordList()));
    autoCompleteTextView.setDropDownBackgroundDrawable(new ColorDrawable(ViewUtils.getWindowBackground(getActivity())));
    autoCompleteTextView.setOnItemClickListener((parent, view, position, id) -> {
        onQueryTextSubmit(parent.getAdapter().getItem(position).toString());
    });

    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:ThirtyDegreesRay,項目名稱:OpenHub,代碼行數:29,代碼來源:SearchActivity.java

示例7: onRestoreInstanceState

import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
protected void onRestoreInstanceState(Parcelable state) {
    SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());
    Menu menu = this.mMenuView != null ? this.mMenuView.peekMenu() : null;
    if (!(ss.expandedMenuItemId == 0 || this.mExpandedMenuPresenter == null || menu == null)) {
        MenuItem item = menu.findItem(ss.expandedMenuItemId);
        if (item != null) {
            MenuItemCompat.expandActionView(item);
        }
    }
    if (ss.isOverflowOpen) {
        postShowOverflowMenu();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:15,代碼來源:Toolbar.java


注:本文中的android.support.v4.view.MenuItemCompat.expandActionView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。