List of usage examples for android.view MenuItem getItemId
public int getItemId();
From source file:net.kourlas.voipms_sms.activities.EditDatabaseActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { switch (item.getItemId()) { case R.id.save_button: List<Message> messages = new ArrayList<>(); try { EditText editText = (EditText) findViewById(R.id.database_text); JSONArray databaseJsonArray = new JSONArray(editText.getText().toString()); for (int i = 0; i < databaseJsonArray.length(); i++) { JSONObject messageJsonObject = databaseJsonArray.getJSONObject(i); Message message = new Message(messageJsonObject.optLong(Database.COLUMN_DATABASE_ID), messageJsonObject.optLong(Database.COLUMN_VOIP_ID), messageJsonObject.getLong(Database.COLUMN_DATE), messageJsonObject.getLong(Database.COLUMN_TYPE), messageJsonObject.getString(Database.COLUMN_DID), messageJsonObject.getString(Database.COLUMN_CONTACT), messageJsonObject.getString(Database.COLUMN_MESSAGE), messageJsonObject.getLong(Database.COLUMN_UNREAD), messageJsonObject.getLong(Database.COLUMN_DELETED), messageJsonObject.getLong(Database.COLUMN_DELIVERED), messageJsonObject.getLong(Database.COLUMN_DELIVERY_IN_PROGRESS)); messages.add(message); }/*from w ww . j av a 2s . c o m*/ } catch (Exception ex) { Utils.showInfoDialog(this, getString(R.string.preferences_database_edit_failure_save)); return false; } database.deleteAllMessages(); for (Message message : messages) { database.insertMessage(message); } finish(); return true; } } return super.onOptionsItemSelected(item); }
From source file:net.reichholf.dreamdroid.fragment.abs.AbstractHttpFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { return onItemSelected(item.getItemId()); }
From source file:com.example.android.notepad.NotesList.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_ITEM_INSERT: // Launch activity to insert a new item startActivity(new Intent(Intent.ACTION_INSERT, getIntent().getData())); return true; case MENU_ITEM_REFRESH: // Ilya: added a refresh button // Perform a managed query. The Activity will handle closing and requerying the cursor // when needed. Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null, Notes.DEFAULT_SORT_ORDER); // Used to map notes entries from the database to views SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor, new String[] { Notes.TITLE }, new int[] { android.R.id.text1 }); setListAdapter(adapter);/*w w w.ja va2 s . c om*/ return true; } return super.onOptionsItemSelected(item); }
From source file:com.loadsensing.app.LlistaXarxesActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // control de les opcions del men switch (item.getItemId()) { case R.id.logout: SharedPreferences settings = getSharedPreferences("LoadSensingApp", Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putString("session", ""); editor.commit();/*from w ww.j av a2 s . co m*/ Log.d(DEB_TAG, "SharedPreferences. Session restarted."); startActivity(new Intent(getApplicationContext(), LoginActivity.class)); this.finish(); return true; case R.id.preferences: startActivity(new Intent(getApplicationContext(), Preferences.class)); return true; case R.id.exit: moveTaskToBack(true); return true; default: return super.onOptionsItemSelected(item); } }
From source file:net.grappendorf.doitlater.TaskEditorActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.delete: return true; }/*from w w w . j ava2 s . c o m*/ return super.onOptionsItemSelected(item); }
From source file:or.tango.android.activity.PicActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { String msg = ""; if (item.getItemId() == 3) { msg = "?"; startActivity(new Intent(this, SettingActivity.class)); }/*from w ww . j av a2 s . c o m*/ showToastMsg(msg); return true; }
From source file:com.sakisds.icymonitor.fragments.history.HistoryPickerFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.item_sort_newestFirst: mSort = "true"; mPullToRefreshLayout.setRefreshing(true); refreshData();/* w w w .j av a 2 s . c o m*/ item.setChecked(true); return true; case R.id.item_sort_oldestFirst: mSort = "false"; mPullToRefreshLayout.setRefreshing(true); refreshData(); item.setChecked(true); return true; } return super.onOptionsItemSelected(item); }
From source file:com.google.developers.actions.debugger.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_refresh: loadActions();/*from www.j a va2 s. c o m*/ break; } return super.onOptionsItemSelected(item); }
From source file:com.meetingninja.csse.user.ProfileFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.edit_item_profile: Intent i = new Intent(getActivity(), EditProfileActivity.class); i.putExtra(Keys.User.PARCEL, new UserParcel(displayedUser)); startActivityForResult(i, 7);// w w w. j a v a 2 s .c o m return true; default: return super.onContextItemSelected(item); } }
From source file:com.dwdesign.tweetings.fragment.SearchTweetsFragment.java
@Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case MENU_SAVE: { final TweetingsApplication application = getApplication(); application.getServiceInterface().createSavedSearch(mAccountId, mQuery); break;/*from ww w . j a va2 s . c om*/ } case MENU_DELETE: { final TweetingsApplication application = getApplication(); application.getServiceInterface().destroySavedSearch(mAccountId, mSearchId); break; } case MENU_ADD_TAB: { CustomTabsAdapter mAdapter; mAdapter = new CustomTabsAdapter(getActivity()); ContentResolver mResolver; mResolver = getContentResolver(); final String tabName = mQuery; final String tabType = AUTHORITY_SEARCH_TWEETS; final String tabIcon = "search"; final long account_id = mAccountId; final String tabArguments = "{\"account_id\":" + account_id + ",\"query\":" + JSONObject.quote(mQuery) + "}"; final ContentValues values = new ContentValues(); values.put(Tabs.ARGUMENTS, tabArguments); values.put(Tabs.NAME, tabName); values.put(Tabs.POSITION, mAdapter.getCount()); values.put(Tabs.TYPE, tabType); values.put(Tabs.ICON, tabIcon); mResolver.insert(Tabs.CONTENT_URI, values); Toast.makeText(this.getActivity(), R.string.search_tab_added, Toast.LENGTH_SHORT).show(); break; } } return super.onOptionsItemSelected(item); }