当前位置: 首页>>代码示例>>Java>>正文


Java MenuItem.getItemId方法代码示例

本文整理汇总了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);
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:11,代码来源:BeenThereActivity.java

示例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);
    }
}
 
开发者ID:kcj8855,项目名称:Ae4Team,代码行数:10,代码来源:PurchaseHistoryActivity.java

示例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);
}
 
开发者ID:FanHuaRan,项目名称:SmackStudy,代码行数:15,代码来源:MainActivity.java

示例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);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:9,代码来源:StickerSelectActivity.java

示例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;
}
 
开发者ID:alewin,项目名称:moneytracking,代码行数:31,代码来源:MainActivity.java

示例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);
    }
}
 
开发者ID:mobilemaster128,项目名称:quickblox-android,代码行数:14,代码来源:ScreenShareFragment.java

示例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);
}
 
开发者ID:adithya321,项目名称:Instincts-2k17,代码行数:10,代码来源:DayViewActivity.java

示例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);
    }
}
 
开发者ID:schul-cloud,项目名称:schulcloud-mobile-android,代码行数:16,代码来源:MainActivity.java

示例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);
}
 
开发者ID:Jugendhackt,项目名称:Camera-warner,代码行数:10,代码来源:SettingsActivity.java

示例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);
}
 
开发者ID:lgyjg,项目名称:AndroidRTC,代码行数:13,代码来源:ConnectActivity.java

示例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);
}
 
开发者ID:daergoth,项目名称:dankbank,代码行数:10,代码来源:MainActivity.java

示例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);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:10,代码来源:CreatePollFragment.java

示例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);
}
 
开发者ID:MuditSrivastava,项目名称:Canvas-Vision,代码行数:10,代码来源:NavActivity.java

示例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);
}
 
开发者ID:d0pam1n,项目名称:DoorPhone,代码行数:11,代码来源:SettingsActivity.java

示例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;
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:36,代码来源:MediaDetailsActivity.java


注:本文中的android.view.MenuItem.getItemId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。