Java Code Examples for android.view.MenuItem.setActionView()

The following are Jave code examples for showing how to use setActionView() of the android.view.MenuItem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Todule-android   File: ToduleListFragment.java   View Source Code Vote up 7 votes
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if(loaderId == DELETED_LOADER_ID){
        inflater.inflate(R.menu.menu_fragment_bin, menu);
    }

    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(R.drawable.ic_search_white_24dp);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM|MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    searchView = new SearchView(myActivity);
    searchView.setMaxWidth(Integer.MAX_VALUE);

    // Set searchbox text to white
    EditText searchEditText = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    searchEditText.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
    searchEditText.setHintTextColor(ContextCompat.getColor(getContext(), R.color.white));

    searchView.setOnQueryTextListener(this);
    item.setActionView(searchView);
    super.onCreateOptionsMenu(menu, inflater);

}
 
Example 2
Project: MiPushFramework   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
public boolean onCreateOptionsMenu (Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    MenuItem item = menu.findItem(R.id.action_enable);
    item.setActionView(R.layout.switch_layout);
    SwitchCompat mSwitchEnablePush = item.getActionView().findViewById(R.id.switchForActionBar);
    mSwitchEnablePush.setChecked(PushController.isAllEnable(this));
    mSwitchEnablePush.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            PushController.setAllEnable(b, MainActivity.this);
            Toast.makeText(MainActivity.this,
                    b ? R.string.msg_enable : R.string.msg_disable
                    , Toast.LENGTH_SHORT).show();
        }
    });
    return true;
}
 
Example 3
Project: android-paypal-example   File: ActionItemBadgeAdder.java   View Source Code Vote up 6 votes
public MenuItem add(Drawable icon, BadgeStyle style, int badgeCount, ActionItemBadge.ActionItemBadgeListener listener) {
    MenuItem item;
    if (groupId != null && itemId != null && order != null) {
        item = menu.add(groupId, itemId, order, title);
    } else {
        item = menu.add(title);
    }

    if (showAsAction != null) {
        item.setShowAsAction(showAsAction);
    }

    item.setActionView(style.getLayout());
    ActionItemBadge.update(activity, item, icon, style, badgeCount, listener);
    return item;
}
 
Example 4
Project: AIMSICDL   File: MapFragment.java   View Source Code Vote up 5 votes
public void setRefreshActionButtonState(final boolean refreshing) {
    if (mOptionsMenu != null) {
        final MenuItem refreshItem = mOptionsMenu.findItem(R.id.get_opencellid);
        if (refreshItem != null) {
            if (refreshing) {
                refreshItem.setActionView(R.layout.actionbar_indeterminate_progress);
            } else {
                refreshItem.setActionView(null);
            }
        }
    }
}
 
Example 5
Project: AIMSICDL   File: MapViewerOsmDroid.java   View Source Code Vote up 5 votes
public void setRefreshActionButtonState(final boolean refreshing) {
    if (mOptionsMenu != null) {
        final MenuItem refreshItem = mOptionsMenu.findItem(R.id.get_opencellid);
        if (refreshItem != null) {
            if (refreshing) {
                refreshItem.setActionView(R.layout.actionbar_indeterminate_progress);
            } else {
                refreshItem.setActionView(null);
            }
        }
    }
}
 
Example 6
Project: Kandroid   File: TaskEditActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case android.R.id.home:
            onBackPressed();
            return true;
        case R.id.action_save:
            ownerId = spinnerProjectUsers.getSelectedItemPosition();
            if (spinnerProjectUsers.getSelectedItemPosition() != 0) {
                for (Enumeration<Integer> iter = projectUsers.keys(); iter.hasMoreElements();) {
                    Integer key = iter.nextElement();
                    if (projectUsers.get(key).contentEquals((String) spinnerProjectUsers.getSelectedItem())) {
                        ownerId = key;
                        break;
                    }
                }
            }
            if (isNewTask) {
                kanboardAPI.createTask(editTextTitle.getText().toString(), projectid, colorId != null ? colorId : defaultColor, columnId, ownerId, null, dueDate, editTextDescription.getText().toString(), null, null, swimlaneId, null, null, null, null, null, null, null, startDate);

            } else {
                kanboardAPI.updateTask(task.getId(), editTextTitle.getText().toString(), colorId != null ? colorId : defaultColor, ownerId, dueDate, editTextDescription.getText().toString(), null, null, null, null, null, null, null, null, null, startDate);
            }
            ProgressBar prog = new ProgressBar(TaskEditActivity.this);
            prog.getIndeterminateDrawable().setColorFilter(Color.WHITE, android.graphics.PorterDuff.Mode.MULTIPLY);
            item.setActionView(prog);
            item.expandActionView();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 7
Project: aos-Video   File: BrowserByNetwork.java   View Source Code Vote up 5 votes
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuItem IndexFolderMenuItem = menu.add(0, R.string.add_to_indexed_folders, Menu.NONE, R.string.add_to_indexed_folders);
    IndexFolderMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_IF_ROOM);
    IndexFolderMenuItem.setActionView(mIndexFolderActionView);

    menu.add(0, R.string.remove_from_indexed_folders, Menu.NONE, R.string.remove_from_indexed_folders)
            .setIcon(R.drawable.ic_menu_video_unindex)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_IF_ROOM);
    menu.add(0, R.string.rescan, Menu.NONE, R.string.rescan);
}
 
Example 8
Project: aos-Video   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean ret = super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.cast_menu, menu);
    if(ArchosVideoCastManager.isCastAvailable()) {
        mMediaRouteMenuItem = VideoCastManager.getInstance().addMediaRouterButton(menu, R.id.media_route_menu_item);
        showOverlay();
        VideoCastManager.getInstance().addVideoCastConsumer(new VideoCastConsumerImpl() {
            @Override
            public void onCastAvailabilityChanged(boolean castPresent) {
                if (castPresent) {
                    showOverlay();
                }
            }
        });
    }
    /// /setHomeButtonsetHomeButton();
    MenuItem item = menu.add(MENU_SEARCH_GROUP, MENU_SEARCH_ITEM, Menu.NONE, R.string.search_title);
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = new SearchView(this);
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    item.setActionView(mSearchView);
    mSearchItem = item;
    MenuItem menuItem = menu.add(MENU_SCRAPER_GROUP, MENU_START_AUTO_SCRAPER_ACTIVITY, Menu.NONE,
            R.string.start_auto_scraper_activity);
    menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setActionProvider(menuItem, mNewVideosActionProvider);
    mNewVideosActionProvider.manageVisibility(menuItem);

    menuItem = menu.add(MENU_PRIVATE_MODE_GROUP, MENU_PRIVATE_MODE_ITEM, Menu.CATEGORY_SECONDARY, R.string.activate_private_mode);
    menuItem.setIcon(R.drawable.ic_menu_private_mode);
    menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    return ret;
}
 
Example 9
Project: Library-Token-Automation   File: MainActivity.java   View Source Code Vote up 5 votes
public void setRefreshActionButtonState(MenuItem refreshItem, final boolean refreshing) {
    //final MenuItem refreshItem = findViewById(R.id.action_refresh);
    if (refreshItem != null) {
        if (refreshing) {
            refreshItem.setActionView(R.layout.actionbar_indeterminate_progress);
        } else {
            refreshItem.setActionView(null);
        }
    }
}
 
Example 10
Project: boohee_v5.6   File: MenuItemCompatHoneycomb.java   View Source Code Vote up 4 votes
public static MenuItem setActionView(MenuItem item, View view) {
    return item.setActionView(view);
}
 
Example 11
Project: boohee_v5.6   File: MenuItemCompatHoneycomb.java   View Source Code Vote up 4 votes
public static MenuItem setActionView(MenuItem item, int resId) {
    return item.setActionView(resId);
}