本文整理汇总了Java中android.support.v7.view.ActionMode类的典型用法代码示例。如果您正苦于以下问题:Java ActionMode类的具体用法?Java ActionMode怎么用?Java ActionMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionMode类属于android.support.v7.view包,在下文中一共展示了ActionMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActionItemClicked
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_send:
List<Item> toTransfer = new ArrayList<>();
for (ItemBagView instance : bagViewMap.values()) {
for (Integer itemPosition : instance.getSelectedItems()) {
toTransfer.add(instance.getItem(itemPosition));
}
}
new AlertDialog.Builder(getActivity())
.setTitle("Transfer to:")
.setAdapter(new ItemBagDestinationAdapter(getContext(), R.layout.view_itembagdestination_row, destinations), (dialog, which) -> {
presenter.sendItems(toTransfer, destinations.get(which).itemBagId);
mode.finish();
})
.show();
}
return true;
}
示例2: initForMode
import android.support.v7.view.ActionMode; //导入依赖的package包/类
public void initForMode(final ActionMode mode) {
if (this.mClose == null) {
this.mClose = LayoutInflater.from(getContext()).inflate(this.mCloseItemLayout, this, false);
addView(this.mClose);
} else if (this.mClose.getParent() == null) {
addView(this.mClose);
}
this.mClose.findViewById(R.id.action_mode_close_button).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mode.finish();
}
});
MenuBuilder menu = (MenuBuilder) mode.getMenu();
if (this.mActionMenuPresenter != null) {
this.mActionMenuPresenter.dismissPopupMenus();
}
this.mActionMenuPresenter = new ActionMenuPresenter(getContext());
this.mActionMenuPresenter.setReserveOverflow(true);
LayoutParams layoutParams = new LayoutParams(-2, -1);
menu.addMenuPresenter(this.mActionMenuPresenter, this.mPopupContext);
this.mMenuView = (ActionMenuView) this.mActionMenuPresenter.getMenuView(this);
this.mMenuView.setBackgroundDrawable(null);
addView(this.mMenuView, layoutParams);
}
示例3: startActionMode
import android.support.v7.view.ActionMode; //导入依赖的package包/类
public ActionMode startActionMode(Callback callback) {
if (this.mActionMode != null) {
this.mActionMode.finish();
}
this.mOverlayLayout.setHideOnContentScrollEnabled(false);
this.mContextView.killMode();
ActionModeImpl mode = new ActionModeImpl(this.mContextView.getContext(), callback);
if (!mode.dispatchOnCreate()) {
return null;
}
mode.invalidate();
this.mContextView.initForMode(mode);
animateToMode(true);
this.mContextView.sendAccessibilityEvent(32);
this.mActionMode = mode;
return mode;
}
示例4: onCreateActionMode
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = getActivity().getMenuInflater();
if (archive) inflater.inflate(R.menu.conversation_list_batch_unarchive, menu);
else inflater.inflate(R.menu.conversation_list_batch_archive, menu);
inflater.inflate(R.menu.conversation_list_batch, menu);
mode.setTitle(R.string.conversation_fragment_cab__batch_selection_mode);
mode.setSubtitle(getString(R.string.conversation_fragment_cab__batch_selection_amount, 1));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
}
return true;
}
示例5: onActionItemClicked
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
boolean consumed = false;
if (mCallback != null) {
consumed = mCallback.onActionItemClicked(mode, item);
}
if (!consumed) {
if (mSupportSubItems) {
SubItemUtil.deleteSelected(mFastAdapter, true, false);
}
else {
mFastAdapter.deleteAllSelectedItems();
}
//finish the actionMode
mode.finish();
}
return consumed;
}
示例6: onPrepareActionMode
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) {
final int checkedCount = mChoiceMode.getCheckedItemCount();
// Show / hide menu items or menu groups based on number of checked items
final MenuItem item = menu.findItem(R.id.action_delete);
item.setVisible(checkedCount > 0);
// Update action mode title
if (checkedCount > 0) {
final Resources resources = getResources();
mode.setTitle(resources.getQuantityString(R.plurals.action_mode_x_items_selected,
checkedCount, checkedCount));
} else {
mode.setTitle(R.string.action_mode_no_items_selected);
}
return true;
}
示例7: onDestroyActionMode
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public void onDestroyActionMode(ActionMode actionMode) {
mListener.onDestroyActionMode(actionMode);
// Clear all the checked items
SparseBooleanArray checkedPositions = mListView.getCheckedItemPositions();
if (checkedPositions != null) {
for (int i = 0; i < checkedPositions.size(); i++) {
mListView.setItemChecked(checkedPositions.keyAt(i), false);
}
}
// Restore the original onItemClickListener
mListView.setOnItemClickListener(mOldItemClickListener);
// Clear the Action Mode
mActionMode = null;
// Reset the ListView's Choice Mode
mListView.post(mSetChoiceModeNoneRunnable);
}
示例8: onActionItemClicked
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
switch (item.getItemId()) {
case R.id.action_delete:
final LongArrayList checkedItems = mChoiceMode.getCheckedItems();
final int size = checkedItems.size();
for (int index = 0; index < size; index++) {
final long itemId = checkedItems.get(index);
mViewModel.deleteById(itemId);
}
mChoiceMode.finish();
return true;
default:
return false;
}
}
示例9: onDestroyActionMode
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public void onDestroyActionMode(ActionMode actionMode) {
mSelection.clearSelection();
/* List adapter could be null, as we could be destroying the action mode of a fragment
* which is in back stack. That fragment had its onDestroyView called, where list
* adapter is set to null.
*/
if (getListAdapter() != null) {
getListAdapter().notifyDataSetChanged();
}
if (mActionModeListener != null) {
mActionModeListener.actionModeDestroyed();
}
announceChangesToActivity();
}
示例10: updateActionModeForSelection
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public void updateActionModeForSelection(int selectedCount, ActionMode.Callback actionMode) {
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, selectedCount, actionMode);
if (mActionMode != null) { /* Action menu is already activated. */
/* Finish action mode if there are no more selected items. */
if (selectedCount == 0) {
mActionMode.finish();
} else {
mActionMode.invalidate();
}
} else { /* No action menu activated - started it. */
if (selectedCount > 0) {
/* Start new action mode. */
mActionMode = startSupportActionMode(actionMode);
}
}
}
示例11: onActionItemClicked
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onActionItemClicked(final ActionMode mode,
MenuItem item) {
if (isAdded() && getView() != null) {
if (item.getTitle().toString().equals(mContext.getString(R.string.favorite))) {
} else {
mode.finish();
}
}
return true;
}
示例12: onDestroyActionMode
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public void onDestroyActionMode(ActionMode actionMode) {
// On configuration change, API level 8 does not handle setting single choice in the middle of process.
if (!multiSelectionFinishedByOnDestroyView) {
setListSingleChoiceMode();
}
isMultiSelectionActive = false;
}
示例13: onDestroyActionMode
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public void onDestroyActionMode(ActionMode mode) {
try {
usersAdapter.clearSelection();
} catch (Exception e) {
Log.e("onDestroyActionMode", e.getMessage(), e);
}
actionMode = null;
toolbar.setVisibility(View.VISIBLE);
}
示例14: onDestroyActionMode
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public void onDestroyActionMode(ActionMode mode) {
if (getView() != null) {
mActionMode = null;
mAdapter.setMode(MODE_SINGLE);
mAdapter.clearSelection();
}
}
示例15: onActionItemClicked
import android.support.v7.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
mUndoHelper.remove(findViewById(android.R.id.content), "Item removed", "Undo", Snackbar.LENGTH_LONG, mFastAdapter.getSelections());
//as we no longer have a selection so the actionMode can be finished
mode.finish();
//we consume the event
return true;
}