當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。