本文整理汇总了Java中android.view.ActionMode类的典型用法代码示例。如果您正苦于以下问题:Java ActionMode类的具体用法?Java ActionMode怎么用?Java ActionMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionMode类属于android.view包,在下文中一共展示了ActionMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPrepareActionMode
import android.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
if(loaderId == INCOMPLETE_LOADER_ID || loaderId == EXPIRED_LOADER_ID){
// remove edit action
menu.removeItem(R.id.action_edit);
}
if (loaderId == DELETED_LOADER_ID){
menu.removeItem(R.id.action_empty_bin);
}
return true;
}
示例2: setChoiceMode
import android.view.ActionMode; //导入依赖的package包/类
@TargetApi(11)
public void setChoiceMode(int choiceMode) {
this.mChoiceMode = choiceMode;
if (VERSION.SDK_INT >= 11 && this.mChoiceActionMode != null) {
if (VERSION.SDK_INT >= 11) {
((ActionMode) this.mChoiceActionMode).finish();
}
this.mChoiceActionMode = null;
}
if (this.mChoiceMode != 0) {
if (this.mCheckStates == null) {
this.mCheckStates = new SparseArrayCompat();
}
if (this.mCheckedIdStates == null && this.mAdapter != null && this.mAdapter.hasStableIds()) {
this.mCheckedIdStates = new LongSparseArray();
}
if (VERSION.SDK_INT >= 11 && this.mChoiceMode == 3) {
clearChoices();
setLongClickable(true);
}
}
}
示例3: onCreateActionMode
import android.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
MenuInflater inflater = actionMode.getMenuInflater();
inflater.inflate(getMenuRes(loaderId), menu);
// Show checkboxes
if(mAdapter instanceof HistoryAdapter){
((HistoryAdapter) mAdapter).setShowCheckbox(true);
} else if (mAdapter instanceof MainCursorAdapter){
((MainCursorAdapter) mAdapter).setShowCheckbox(true);
}
actionMode.setTitle(selectedIds.size() + " selected");
mActionMode = actionMode;
return true;
}
示例4: resolveActionMode
import android.view.ActionMode; //导入依赖的package包/类
/**
* 处理item,处理点击
* @param actionMode
*/
private ActionMode resolveActionMode(ActionMode actionMode) {
if (actionMode != null) {
final Menu menu = actionMode.getMenu();
mActionMode = actionMode;
menu.clear();
for (int i = 0; i < mActionList.size(); i++) {
menu.add(mActionList.get(i));
}
for (int i = 0; i < menu.size(); i++) {
MenuItem menuItem = menu.getItem(i);
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
getSelectedData((String) item.getTitle());
releaseAction();
return true;
}
});
}
}
mActionMode = actionMode;
return actionMode;
}
示例5: performLongPress
import android.view.ActionMode; //导入依赖的package包/类
boolean performLongPress(View child, int longPressPosition, long longPressId) {
boolean z = true;
if (VERSION.SDK_INT < 11 || this.mChoiceMode != 3) {
z = false;
if (this.mOnItemLongClickListener != null) {
z = this.mOnItemLongClickListener.onItemLongClick(this, child, longPressPosition, longPressId);
}
if (!z) {
this.mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
z = super.showContextMenuForChild(this);
}
if (z) {
performHapticFeedback(0);
}
} else if (this.mChoiceActionMode == null) {
ActionMode startActionMode = startActionMode((MultiChoiceModeWrapper) this.mMultiChoiceModeCallback);
this.mChoiceActionMode = startActionMode;
if (startActionMode != null) {
setItemChecked(longPressPosition, true);
performHapticFeedback(0);
}
}
return z;
}
示例6: onItemCheckedStateChanged
import android.view.ActionMode; //导入依赖的package包/类
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
if (checked) {
// Directories and footer items cannot be checked
boolean valid = false;
final Cursor cursor = mAdapter.getItem(position);
if (cursor != null) {
final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
// if (!Document.MIME_TYPE_DIR.equals(docMimeType)) {
valid = isDocumentEnabled(docMimeType, docFlags);
// }
}
if (!valid) {
mCurrentView.setItemChecked(position, false);
}
}
int count = mCurrentView.getCheckedItemCount();
mode.setTitle(getResources().getString(R.string.mode_selected_count, count));
if (count == 1 || count == 2) {
mode.invalidate();
}
}
示例7: onDestroyActionMode
import android.view.ActionMode; //导入依赖的package包/类
@Override
public void onDestroyActionMode(ActionMode mode) {
actionMode = null;
mSelectAll = null;
mMarkAsRead = null;
mMarkAsUnread = null;
mFlag = null;
mUnflag = null;
setSelectionState(false);
}
示例8: onCreateActionMode
import android.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.message_list_context, menu);
// check capabilities
setContextCapabilities(account, menu);
return true;
}
示例9: onActionModeStarted
import android.view.ActionMode; //导入依赖的package包/类
@Override
public void onActionModeStarted(ActionMode mode) {
super.onActionModeStarted(mode);
Window window = getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorAccentDark));
}
示例10: onDestroyActionMode
import android.view.ActionMode; //导入依赖的package包/类
@Override
public void onDestroyActionMode(ActionMode mode) {
mWrapped.onDestroyActionMode(mode);
mChoiceActionMode = null;
// Ending selection mode means deselecting everything.
clearChoices();
updateOnScreenCheckedViews();
// rememberSyncState();
requestLayout();
setLongClickable(true);
}
示例11: onClick
import android.view.ActionMode; //导入依赖的package包/类
@Override
public void onClick(final View v) {
final int position = mCurrentView.getPositionForView(v);
if (position != ListView.INVALID_POSITION) {
int count = mCurrentView.getCheckedItemCount();
switch (v.getId()) {
case android.R.id.icon:
if (count == 0) {
ActionMode mChoiceActionMode = null;
if (mChoiceActionMode == null && (mChoiceActionMode = mCurrentView.startActionMode(mMultiListener)) != null) {
mCurrentView.setItemChecked(position, true);
mCurrentView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
} else {
mCurrentView.setItemChecked(position, !mCurrentView.isItemChecked(position));
mCurrentView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
break;
case R.id.button_popup:
v.post(new Runnable() {
@Override
public void run() {
showPopupMenu(v, position);
}
});
break;
}
}
}
示例12: onCreateActionMode
import android.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
URLogs.d("actionmode---" + (mode == null));
mode.getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
// return false;
}
示例13: onCreateActionMode
import android.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mActionMode = mode;
MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
return true;
}
示例14: confirmCheckedPositionsById
import android.view.ActionMode; //导入依赖的package包/类
void confirmCheckedPositionsById() {
this.mCheckStates.clear();
boolean checkedCountChanged = false;
int checkedIndex = 0;
while (checkedIndex < this.mCheckedIdStates.size()) {
long id = this.mCheckedIdStates.keyAt(checkedIndex);
int lastPos = ((Integer) this.mCheckedIdStates.valueAt(checkedIndex)).intValue();
if (id != this.mAdapter.getItemId(lastPos)) {
int start = Math.max(0, lastPos - 20);
int end = Math.min(lastPos + 20, this.mItemCount);
boolean found = false;
for (int searchPos = start; searchPos < end; searchPos++) {
if (id == this.mAdapter.getItemId(searchPos)) {
found = true;
this.mCheckStates.put(searchPos, Boolean.valueOf(true));
this.mCheckedIdStates.setValueAt(checkedIndex, Integer.valueOf(searchPos));
break;
}
}
if (!found) {
this.mCheckedIdStates.delete(id);
checkedIndex--;
this.mCheckedItemCount--;
checkedCountChanged = true;
if (!(VERSION.SDK_INT <= 11 || this.mChoiceActionMode == null || this.mMultiChoiceModeCallback == null)) {
((MultiChoiceModeWrapper) this.mMultiChoiceModeCallback).onItemCheckedStateChanged((ActionMode) this.mChoiceActionMode, lastPos, id, false);
}
}
} else {
this.mCheckStates.put(lastPos, Boolean.valueOf(true));
}
checkedIndex++;
}
if (checkedCountChanged && this.mChoiceActionMode != null && VERSION.SDK_INT > 11) {
((ActionMode) this.mChoiceActionMode).invalidate();
}
}
示例15: onCreateActionMode
import android.view.ActionMode; //导入依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
TerminalTextViewOverlay.this.selectionActionMode = mode;
menu.clear();
menu.add(0, COPY, 0, R.string.console_menu_copy)
.setIcon(R.drawable.ic_action_copy)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_IF_ROOM);
menu.add(0, PASTE, 1, R.string.console_menu_paste)
.setIcon(R.drawable.ic_action_paste)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_IF_ROOM);
return true;
}