本文整理汇总了Java中android.view.MenuItem.getOrder方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.getOrder方法的具体用法?Java MenuItem.getOrder怎么用?Java MenuItem.getOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.getOrder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNavigationItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(final MenuItem menuItem) {
if (menuItem.getItemId() != R.id.navigation_item_settings) {
if (mSelectedNavigationPosition != menuItem.getOrder() ||
mSelectedAccountId != mAccounts.get(0).id()) {
mPager.post(new Runnable() {
@Override
public void run() {
mPager.setCurrentItem(menuItem.getOrder(), false);
}
});
}
selectNavigation(menuItem);
} else {
ActivityCompat.startActivity(this, new Intent(this, SettingsActivity.class), null);
}
return true;
}
示例2: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
int clickedItemPosition = item.getOrder();
TodoEvent event = eventList.get(clickedItemPosition);
switch (item.getItemId()) {
case 1:
event.delete();
eventList.remove(clickedItemPosition);
MyAdapter.notifyItemRangeRemoved(clickedItemPosition, 1);
MyAdapter.setTodoEventSize(MyAdapter.getTodoEventSize()-1);
Snackbar.make(MyAdapter.getHolder().itemView,"你删掉了这条项目",Snackbar.LENGTH_SHORT).show();
showNoEvent();
break;
default:
break;
}
return super.onContextItemSelected(item);
}
示例3: onNavigationItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int order = item.getOrder();
if (order >= 0 && order <= 3) {
handleToolbarElevation(order);
switchFragment(order);
return true;
}
return false;
}
示例4: onMenuItemClick
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getOrder()) {
case 0:
Intent intent = new Intent(getActivity(), WeatherActivity.class);
startActivity(intent);
return true;
case 1:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View alertDialogView = LayoutInflater.from(getActivity()).inflate(R.layout.alert_add_todo, null);
builder.setView(alertDialogView);
final EditText contentEt = (EditText) alertDialogView.findViewById(R.id.contentEt);
builder.setMessage(R.string.please_type);
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String todoContent = contentEt.getText().toString();
if (todoContent.length() > 0) {
localTodoData.add(todoContent);
SharedPreferencesUtil.saveLocalTodos(localTodoData, getActivity());
contentEt.setText("");
fetchData();
}
}
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.create().show();
return true;
default:
return false;
}
}
示例5: selectNavigation
import android.view.MenuItem; //导入方法依赖的package包/类
public void selectNavigation(MenuItem menuItem) {
mSelectedAccountId = mAccounts.get(0).id();
mSelectedNavigationPosition = menuItem.getOrder();
setTitle(menuItem.getTitle());
menuItem.setChecked(true);
mDrawerLayout.closeDrawers();
}
示例6: compare
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public int compare(MenuItem o1, MenuItem o2) {
return o1.getOrder() - o2.getOrder();
}