本文整理汇总了Java中android.view.MenuItem.getItemId方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.getItemId方法的具体用法?Java MenuItem.getItemId怎么用?Java MenuItem.getItemId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.getItemId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case android.R.id.home:
onBackPressed();
break;
}
return super.onOptionsItemSelected(item);
}
示例2: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
IntentBack();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例3: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
示例4: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
示例5: onNavigationItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.nav_home) {
Intent intent = new Intent(MainActivity.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
} else if (id == R.id.nav_planned) {
startActivity(new Intent(MainActivity.this, PlannedActivity.class));
} else if (id == R.id.nav_category) {
startActivity(new Intent(MainActivity.this, CategoriesActivity.class));
} else if (id == R.id.nav_graph) {
startActivity(new Intent(MainActivity.this, ChartTypeActivity.class));
} else if (id == R.id.nav_archive) {
startActivity(new Intent(MainActivity.this, ArchiveActivity.class));
} else if (id == R.id.nav_report) {
startActivity(new Intent(MainActivity.this, ReportActivity.class));
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return false;
}
示例6: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.stop_screen_share:
Log.d(TAG, "stop_screen_share");
if (onSharingEvents != null) {
onSharingEvents.onStopPreview();
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例7: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
break;
}
return super.onOptionsItemSelected(item);
}
示例8: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.main_action_settings:
startActivity(new Intent(this, SettingsActivity.class));
return true;
case R.id.main_action_logout:
goToSignIn();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例9: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
// When the home button is pressed, take the user back to the VisualizerActivity
if (id == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this);
}
return super.onOptionsItemSelected(item);
}
示例10: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
if (item.getItemId() == REMOVE_FAVORITE_INDEX) {
AdapterView.AdapterContextMenuInfo info =
(AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
roomList.remove(info.position);
adapter.notifyDataSetChanged();
return true;
}
return super.onContextItemSelected(item);
}
示例11: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
return true;
}
return super.onOptionsItemSelected(item);
}
示例12: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case (R.id.add_menu):
getPresenter().fireDoneClick();
return true;
}
return super.onOptionsItemSelected(item);
}
示例13: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home)
{
finish();
}
return super.onOptionsItemSelected(item);
}
示例14: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
startActivity(new Intent(getActivity(), SettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
示例15: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.save_media) {
switch (mediaType) {
case 1: // text
DateTime now = DateTime.now();
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
JournalEntry currentEntry = new JournalEntry();
currentEntry.setCaption(entry_caption.getText().toString());
currentEntry.setType(mediaType);
currentEntry.setLat(ALLENDALE_LAT);
currentEntry.setLng(ALLENDATE_LNG);
currentEntry.setDate(fmt.print(now));
DatabaseReference savedEntry = entriesRef.push();
savedEntry.setValue(currentEntry);
Snackbar.make(entry_caption,
"Your entry is saved",
Snackbar.LENGTH_LONG).show();
break;
case 2: // photo
uploadMedia(mediaType, "image/jpeg", "photos");
break;
case 3: // audio
uploadMedia(mediaType, "audio/m4a", "audio");
break;
case 4: // video
uploadMedia(mediaType, "video/mp4", "videos");
break;
}
return true;
}
return false;
}