private void selectItemFriends(int position) { Fragment newChatFragment = new NewChatFragment(); Bundle args = new Bundle(); String message = friendsAdapter.getItem(position).getMessage(); String sender = friendsAdapter.getItem(position).getSender(); friendsAdapter.getItem(position).setCount(0); args.putString("displaytext", message); newChatFragment.setArguments(args); FragmentManager fragmentManager = getFragmentManager(); fragmentManager .beginTransaction() .replace(R.id.content_frame, newChatFragment, "newchatfragment") .commit(); mRightDrawerList.setItemChecked(position, true); mLeftDrawerList.setItemChecked(mNavPosition, false); mNavPosition = position; setTitle(sender); mDrawerLayout.closeDrawer(mRightDrawerList); }
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.edit_tracks_edit: Track t = (Track) tracksAdapter.getItem((int) info.id); Intent intent = new Intent(this, EditTrackActivity.class); intent.putExtra("track_id", t.getId()); startActivityForResult(intent, 1); return true; /* case R.id.edit_tracks_deactivate: Track t2 = (Track)tracksAdapter.getItem((int)info.id); TracksDataSource ds = new TracksDataSource(this); ds.open(); ds.deleteTrack(t2); ds.close(); loadTracks(); return true; */ case R.id.edit_tracks_delete: Track t3 = (Track) tracksAdapter.getItem((int) info.id); TracksDataSource ds2 = new TracksDataSource(this); ds2.open(); ds2.deleteTrack(t3); ds2.close(); loadTracks(); return true; } return super.onContextItemSelected(item); }
@Override public void onListItemClick(ListView l, View v, int position, long id) { Toast t = Toast.makeText( getActivity(), "call Message" + "-" + adapter.getItem(position), Toast.LENGTH_SHORT); t.show(); currentPeer = adapter.getItem(position); listItemLisener.reLoadSelectedTabView(); }
@Override public void onItemSelected(AdapterView<?> parent, View view, final int position, long id) { final ArrayAdapter<String> adapter = ((ArrayAdapter<String>) mUnits.getAdapter()); if (mEvents != null && mCurrentUnit != null && !adapter.getItem(position).equals(mCurrentUnit)) { mEvents.onUnitChange(mUnits.getItemAtPosition(position).toString()); mCurrentUnit = adapter.getItem(position); } }
@Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { String previous = mViewPagerAdapter.getSelectedPulseTarget(); getSupportActionBar().setSelectedNavigationItem(itemPosition); mViewPagerAdapter.setSelectedPulseTarget(mSpinnerAdapter.getItem(itemPosition)); if (!previous.equals(mSpinnerAdapter.getItem(itemPosition))) { Log.d(LOG_TAG, "Switching chapter!"); mViewPagerAdapter.notifyDataSetChanged(); } return true; }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { DictEntryDialogFragment deFrag = new DictEntryDialogFragment(); Bundle args = new Bundle(); args.putString(DictEntryDialogFragment.KEY_TITLE, getString(R.string.title_diag_edit_dict_ent)); args.putString( DictEntryDialogFragment.KEY_ENT, adap.getItem(position).getDataString(getContext())); args.putInt(DictEntryDialogFragment.KEY_ENT_ID, adap.getItem(position).getId()); deFrag.setArguments(args); deFrag.show(getActivity().getFragmentManager(), "deFrag"); }
public void cancelTask(String key) { /* Removes a task from the list view with a given key. Also deletes data about this task from appData. */ for (int i = 0; i < adapter.getCount(); i++) if (adapter.getItem(i).getKey().equals(key)) { Task task = adapter.getItem(i); adapter.remove(task); keys.remove(task.getKey()); SharedPreferences.Editor edit = appData.edit(); edit.remove(key); edit.apply(); } }
public static void retorneListaNomesEventos( String eventoFavorito1, String eventoFavorito2, String eventoFavorito3, ArrayAdapter<CharSequence> ar) { nomesEventosTelaPrincipal.add(eventoFavorito1); nomesEventosTelaPrincipal.add(eventoFavorito2); nomesEventosTelaPrincipal.add(eventoFavorito3); for (int i = 0; i < ar.getCount(); i++) { if (!nomesEventosTelaPrincipal.contains(ar.getItem(i).toString())) { nomesEventosTelaPrincipal.add(ar.getItem(i).toString()); } } }
/** * Attempts to sign in or register the account specified by the login form. If there are form * errors (invalid email, missing fields, etc.), the errors are presented and no actual login * attempt is made. */ private void attemptLogin() { if (mAuthTask != null) { return; } // Reset errors. mNameView.setError(null); mZipCodeView.setError(null); // Store values at the time of the login attempt. String name = mNameView.getText().toString(); String phone = mPhoneView.getText().toString(); String bloodgroup = adapter.getItem(mBloodGroupsView.getSelectedItemPosition()).toString(); String zipcode = mZipCodeView.getText().toString(); boolean cancel = false; View focusView = null; // Check for a valid password, if the user entered one. if (TextUtils.isEmpty(zipcode) || !isZipCodeValid(zipcode)) { mZipCodeView.setError("Invalid Zip Code"); focusView = mZipCodeView; cancel = true; } // Check for a valid email address. if (TextUtils.isEmpty(name)) { mNameView.setError(getString(R.string.error_field_required)); focusView = mNameView; cancel = true; } else if (isEmailValid(name)) { mNameView.setError("Invalid Name"); focusView = mNameView; cancel = true; } if (TextUtils.isEmpty(phone)) { mPhoneView.setError("This field is required"); focusView = mPhoneView; cancel = true; } if (mBloodGroupsView.getSelectedItemPosition() < 1) { Snackbar.make(mBloodGroupsView, "Choose your Blood Group", Snackbar.LENGTH_SHORT).show(); focusView = mBloodGroupsView; cancel = true; } if (cancel) { // There was an error; don't attempt login and focus the first // form field with an error. focusView.requestFocus(); } else { // Show a progress spinner, and kick off a background task to // perform the user login attempt. showProgress(true); mAuthTask = new UserLoginTask(name, phone, bloodgroup, zipcode); // showProgress(true); mAuthTask.execute((Void) null); } }
protected void b(String s, int i) { boolean flag = true; nz.b( "ToolboxListActivity", (new StringBuilder()).append("package changed: ").append(s).toString()); int j = b.getCount(); int k = 0; do { ou ou1; label0: { if (k < j) { ou1 = (ou) b.getItem(k); if (ou1 != null) { break label0; } } return; } if (s.equals(ou1.f)) { if (i != flag) { flag = false; } ou1.t = flag; b.notifyDataSetChanged(); return; } k++; } while (true); }
@Override public void remove(int which) { DragSortListView list = getListView(); String item = adapter.getItem(which); adapter.remove(item); list.removeCheckState(which); }
public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int menuItemIndex = item.getItemId(); Interes interes = interesesAdapter.getItem(info.position); switch (menuItemIndex) { case R.id.ItemMenuBorrar: OrmLiteSqliteOpenHelper helper = null; try { helper = OpenHelperManager.getHelper(this, DatabaseHelper.class); Dao<Interes, Integer> interesesDao = helper.getDao(Interes.class); interesesDao.delete(interes); interesesAdapter.remove(interes); } catch (Exception e) { Log.e(TAG, "Error al listar los intereses", e); GuiUtils.mostrarToast(this, R.string.operacion_error, null); } finally { try { OpenHelperManager.releaseHelper(); } catch (Exception e2) { } } return true; case R.id.ItemMenuEditar: mostrarDatosInteres(interes); return true; default: return super.onContextItemSelected(item); } }
private void loadLanguages() { mLocaleAdapter = com.android.internal.app.LocalePicker.constructAdapter( getActivity(), R.layout.locale_picker_item, R.id.locale); mInitialLocale = Locale.getDefault(); mCurrentLocale = mInitialLocale; mAdapterIndices = new int[mLocaleAdapter.getCount()]; int currentLocaleIndex = 0; String[] labels = new String[mLocaleAdapter.getCount()]; for (int i = 0; i < mAdapterIndices.length; i++) { com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo = mLocaleAdapter.getItem(i); Locale localLocale = localLocaleInfo.getLocale(); if (localLocale.equals(mCurrentLocale)) { currentLocaleIndex = i; } mAdapterIndices[i] = i; labels[i] = localLocaleInfo.getLabel(); } mLanguagePicker.setDisplayedValues(labels); mLanguagePicker.setMaxValue(labels.length - 1); mLanguagePicker.setValue(currentLocaleIndex); mLanguagePicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); mLanguagePicker.setOnValueChangedListener( new LocalePicker.OnValueChangeListener() { public void onValueChange(LocalePicker picker, int oldVal, int newVal) { setLocaleFromPicker(); } }); }
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub String cityName = arrayAdapter.getItem(position); // String cityName=list.get(position) textView.setText("您选择的城市是" + cityName); }
@UiThreadTest public void testMakeTweet() { LonelyTwitterActivity lta = (LonelyTwitterActivity) getActivity(); int oldLength = lta.getAdapter().getCount(); makeTweet("test string"); ArrayAdapter<Tweet> arrayAdapter = lta.getAdapter(); assertEquals(oldLength + 1, arrayAdapter.getCount()); assertTrue( "Did you add a Tweet object?", arrayAdapter.getItem(arrayAdapter.getCount() - 1) instanceof Tweet); Tweet tweet = arrayAdapter.getItem(arrayAdapter.getCount() - 1); assertEquals("This is not the text we expected!", tweet.getMessage(), "test string"); }
/** On item clicked */ @Override public void onItemClick(AdapterView<?> list, View item, int position, long id) { final String command = adapter.getItem(position); String[] items = {getResources().getString(R.string.action_remove)}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(command); builder.setItems( items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { switch (item) { case 0: // Remove adapter.remove(command); commands.remove(command); okButton.setEnabled(true); break; } } }); AlertDialog alert = builder.create(); alert.show(); }
@Override public String writeToModel(Task task) { UrgencyValue item = urgencyAdapter.getItem(spinner.getSelectedItemPosition()); if (item.dueDate != SPECIFIC_DATE) // user canceled specific date task.setValue(Task.DUE_DATE, item.dueDate); return null; }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { int position = ((AdapterView.AdapterContextMenuInfo) menuInfo).position; if (position >= adapter.getCount() || adapter.getItem(position).getResult() != null) { menu.add(Menu.NONE, position, position, RHelper.getString("history_clear_one_history_text")); } // else it's just that dummy "Empty" message }
public void onReceive(Context context, Intent intent) { String action = intent.getAction(); // When discovery finds a device if (BluetoothDevice.ACTION_FOUND.equals(action)) { // Get the BluetoothDevice object from the Intent BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); // If it's already paired, skip it, because it's been listed already if (device.getBondState() != BluetoothDevice.BOND_BONDED) { String strNoFound = getIntent().getStringExtra("no_devices_found"); if (strNoFound == null) strNoFound = "No devices found"; if (mPairedDevicesArrayAdapter.getItem(0).equals(strNoFound)) { mPairedDevicesArrayAdapter.remove(strNoFound); } mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress()); } // When discovery is finished, change the Activity title } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) { setProgressBarIndeterminateVisibility(false); String strSelectDevice = getIntent().getStringExtra("select_device"); if (strSelectDevice == null) strSelectDevice = "Select a device to connect"; setTitle(strSelectDevice); } }
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Xlog.e( TAG, "arg0.getId(): " + arg1.getId() + " " + R.id.WiFi_RX_Channel_Spinner + " " + R.id.WiFi_Bandwidth_Spinner); if (arg0.getId() == R.id.WiFi_RX_Channel_Spinner) { if (EMWifi.sIsInitialed) { mChannel.mChannelSelect = mChannelAdapter.getItem(arg2); EMWifi.setChannel(mChannel.getChannelFreq()); } else { showDialog(DIALOG_WIFI_ERROR); } } else if (arg0.getId() == R.id.WiFi_Bandwidth_Spinner) { mBandwidthIndex = arg2 < mBandwidth.length ? arg2 : mBandwidthIndex; if (mBandwidth[BW_INDX_ADVANCED].equals( mBandwidthSpinner.getSelectedItem().toString())) { mBandwidthIndex = BW_INDX_ADVANCED; } if (mBandwidthIndex == BW_INDX_ADVANCED) { onAdvancedBandwidthSelected(); } else { updateChannels(); findViewById(R.id.wifi_bandwidth_advanced_ll).setVisibility(View.GONE); } } }
/** UPDATE GRAPH WITH SELECTED when results are returned */ private void updateGraphWithSelected(String results) { ndb = new NutritionDatabaseHelper(this); if (selectedItems != null || quantities != null) { selectedItems.clear(); quantities.clear(); } else { selectedItems = new ArrayList<Item>(); quantities = new ArrayList<Integer>(); } int position = -1; for (int i = 0; i < ccartList.getCount(); i++) { String tempItemName = ccartList.getItem(i); int pos = tempItemName.indexOf(" "); String compare = tempItemName.substring(pos + 1); if (compare.equals(results)) { position = i; break; } else { continue; } } Item selectedItem = ndb.getItem(results); ndb.close(); selectedItems.add(selectedItem); String itemOne; if (selectedItems.get(0).getItemName().length() > 20) { itemOne = selectedItems.get(0).getItemName().substring(0, 20) + "..."; } else { itemOne = selectedItems.get(0).getItemName(); } String one = "<font color='#7EAD1A'>" + itemOne + "</font> SELECTED"; added.setText(Html.fromHtml(one)); for (GroceryItem gItem : ccart) { if (gItem.getItemName().equals(results)) { quantities.add(gItem.getQuantity()); Log.d("CartActivity: ", "Name: " + gItem.getItemName() + quantities.get(0)); } } Log.d("CartActivity", "Position: " + position); sd_list.setItemChecked(position, true); graph.passSelectedItems(selectedItems); graph.passSelectedQuantities(quantities); graph.postInvalidate(); graphLabels.setDays(days); graphLabels.postInvalidate(); }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (null != mListener) { Debtor debtor = (Debtor) mAdapter.getItem(position); mListener.onFragmentInteractionNewTransaction( null, null, debtor.getIdAsString(), debtor.getName()); } }
private String getSelectedModel() { try { int position = modelListView.getCheckedItemPosition(); return modelNamesAdapter.getItem(position); } catch (Exception e) { return null; } }
@Override public long getItemId(int paramInt) { String currentSpriteName = spinnerAdapter.getItem(paramInt); if (!currentSpriteName.equals(context.getString(R.string.new_broadcast_message))) { oldSelectedObject = currentSpriteName; } return spinnerAdapter.getItemId(paramInt); }
@Override public void onItemSelected( final AdapterView<?> parent, final View view, final int position, final long id) { final Fragment fragment = Fragment.instantiate(this, mAdapter.getItem(position).cls.getName()); final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(android.R.id.content, fragment); ft.commit(); }
@Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Intent i = new Intent(this, NoteEdit.class); AppNote note = listAdapter.getItem((int) id); i.putExtra(AppNote._ID, note.getId()); startActivityForResult(i, EDITOR_ACTIVITY); }
/** @return Actual selected groups from adapter. */ public ArrayList<String> getSelected() { ArrayList<String> groups = new ArrayList<>(); for (int position = 0; position < arrayAdapter.getCount(); position++) if (listView.isItemChecked(position + listView.getHeaderViewsCount())) { groups.add(arrayAdapter.getItem(position)); } return groups; }
private int findPosition(String key) { if (key.equals("latest")) key = "CONUS"; for (int i = 0; i < dataAdapter.getCount(); i++) if (key.equals(dataAdapter.getItem(i))) return i; return 0; }
/** * @see android.app.ListActivity#onListItemClick(android.widget.ListView, android.view.View, int, * long) */ @Override protected void onListItemClick(ListView l, View v, int position, long id) { Project selectedProject = mAdapter.getItem(position); storeProjectInfo(selectedProject.getId(), selectedProject.getName()); finish(); }
private String waypointsToString(ArrayAdapter<RouteEditorActivity.Waypoint> waypoints) { StringBuilder builder = new StringBuilder(); for (int i = 1; i < waypoints.getCount() - 1; i++) { builder.append(positionToString(waypoints.getItem(i).getMarkerOptions().getPosition())); builder.append("|"); } return builder.toString(); }