本文整理匯總了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();
}