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