Java Code Examples for android.widget.AdapterView#getId()
The following examples show how to use
android.widget.AdapterView#getId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChatsFragment.java From barterli_android with Apache License 2.0 | 6 votes |
@Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { if (parent.getId() == R.id.list_chats) { final Cursor cursor = (Cursor) mChatsAdapter.getItem(position); loadChat( cursor.getString(cursor.getColumnIndex(DatabaseColumns.USER_ID)), cursor.getString(cursor.getColumnIndex(DatabaseColumns.CHAT_ID)), true, null ); } }
Example 2
Source File: EnableSystemAppsByIntentFragment.java From android-testdpc with Apache License 2.0 | 6 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.list_of_actions: if (position == ACTIONS_LIST.length - 1) { showCustomActionInputDialog(); } else { mActions.clear(); mActions.add(ACTIONS_LIST[position]); updateStatusTextView(); } return; default: break; } super.onItemSelected(parent, view, position, id); }
Example 3
Source File: EditFragment.java From Passbook with Apache License 2.0 | 6 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { if(parent.getId() == R.id.category) { mPosition = pos; } else { EntryHolder eh = (EntryHolder)parent.getTag(); int type = pos + 1; eh.mEntryItem.mType = type; eh.mValueField.setInputType(INPUT_TYPES[type]); if(type == AccountManager.EntryType.PASSWORD || type == AccountManager.EntryType.PIN) { eh.mAutoPwd.setVisibility(View.VISIBLE); } else { eh.mAutoPwd.setVisibility(View.INVISIBLE); } } }
Example 4
Source File: WifiConfigCreationDialog.java From android-testdpc with Apache License 2.0 | 6 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { if (parent.getId() == R.id.security) { mSecurityType = pos; switch (mSecurityType) { case SECURITY_TYPE_NONE: mPasswordView.setVisibility(View.GONE); break; case SECURITY_TYPE_WPA: mPasswordText.setHint(mOldConfig == null ? R.string.minimum_limit : R.string.wifi_unchanged); // Fallthrough case SECURITY_TYPE_WEP: mPasswordView.setVisibility(View.VISIBLE); mPasswordText.requestFocus(); break; } } enableSaveButtonIfAppropriate(); }
Example 5
Source File: QueryCityActivity.java From WayHoo with Apache License 2.0 | 6 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.cityList: City city = mSearchCityAdapter.getItem(position); L.i("liweiping", city.getName()); addToTmpCityTable(city); break; case R.id.hotCityGrid: City hotCity = mHotCitys.get(position); L.i("liweiping", hotCity.getName()); addToTmpCityTable(hotCity); break; default: break; } }
Example 6
Source File: MongolLabelActivity.java From mongol-library with MIT License | 6 votes |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { int viewId = parent.getId(); if (viewId == R.id.fontcolor_spinner) { int color = Color.BLACK; String item = String.valueOf(parent.getItemAtPosition(pos)); switch (item) { case "BLUE": color = Color.BLUE; break; case "RED": color = Color.RED; break; case "YELLOW": color = Color.YELLOW; break; } mMongolLabelMatchParent.setTextColor(color); mMongolLabelWrapContent.setTextColor(color); } else if (viewId == R.id.fontsize_spinner) { int size = Integer.parseInt(parent.getSelectedItem().toString()); mMongolLabelMatchParent.setTextSize(size); mMongolLabelWrapContent.setTextSize(size); } }
Example 7
Source File: PolygonDemoActivity.java From android-samples with Apache License 2.0 | 5 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { switch (parent.getId()) { case R.id.strokeJointTypeSpinner: mutablePolygon.setStrokeJointType(getSelectedJointType(pos)); break; case R.id.strokePatternSpinner: mutablePolygon.setStrokePattern(getSelectedPattern(pos)); break; } }
Example 8
Source File: Spinner_Fragment.java From ui with Apache License 2.0 | 5 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent.getId() == R.id.spinner1) { // used to control the seekbar if (position !=-1) //-1 is nothing selected. just making sure. mySeekBar.setProgress (position); //just use position, don't care about the text itself themselves. } else { //this case, I want the text in the spinner box. Toast.makeText(myContext, parent.getAdapter().getItem(position).toString(), Toast.LENGTH_LONG).show(); } }
Example 9
Source File: AddItemShoppingList.java From ShoppingList with MIT License | 5 votes |
@Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { /* ListView lvItensShoppingList - R.id.lvItemShoppingList */ if (arg0.getId() == findViewById(R.id.lvItemShoppingList).getId()) { int position = arg2 - 1; if (adapter.getIdSelected() != adapter.getItem(position).getId()) { // Call the methodo onCreateOptionsMenu again ActivityCompat.invalidateOptionsMenu(this); setViewValues(adapter.getItem(position).getDescription(), adapter.getItem(position).getUnitValue(), adapter.getItem(position).getQuantity()); adapter.setIdSelected(adapter.getItem(position).getId()); refreshAdapter(); } } else /* AutoCompleteTextView - R.id.edDescription */ if (arg0.getAdapter().getItem(arg2) instanceof String) { ItemShoppingList itemShoppingList; try { itemShoppingList = ItemShoppingListDAO.findLastInserted(this, (String) arg0.getAdapter().getItem(arg2)); setViewValues(itemShoppingList.getDescription(), itemShoppingList.getUnitValue(), itemShoppingList.getQuantity()); } catch (VansException e) { e.printStackTrace(); Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); } } }
Example 10
Source File: CornerDrawableActivity.java From ProjectX with Apache License 2.0 | 5 votes |
@SuppressLint("RtlHardcoded") @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.cnd_sp_direction: switch (position) { default: case 0: mDrawable.setDirection(Gravity.TOP); break; case 1: mDrawable.setDirection(Gravity.START); break; case 2: mDrawable.setDirection(Gravity.END); break; case 3: mDrawable.setDirection(Gravity.BOTTOM); break; } // 因View不自动更新Padding,此处需要重新设置Padding setBackground(null); setBackground(mDrawable); break; case R.id.cnd_sp_location: switch (position) { default: case 0: mDrawable.setLocation(Gravity.CENTER, mDrawable.getCornerMargin()); break; case 1: mDrawable.setLocation(Gravity.START, mDrawable.getCornerMargin()); break; case 2: mDrawable.setLocation(Gravity.END, mDrawable.getCornerMargin()); break; } break; } }
Example 11
Source File: IntentOrIntentFilterFragment.java From android-testdpc with Apache License 2.0 | 5 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.list_of_actions: if (position == ACTIONS_LIST.length - 1) { showCustomInputDialog(getString(R.string.actions_title), CUSTOM_INPUT_TYPE_ACTIONS); } break; case R.id.list_of_categories: if (position == CATEGORIES_LIST.length - 1) { showCustomInputDialog(getString(R.string.categories_title), CUSTOM_INPUT_TYPE_CATEGORIES); } break; case R.id.list_of_data_schemes: if (position == DATA_SCHEMES_LIST.length - 1) { showCustomInputDialog(getString(R.string.data_schemes_title), CUSTOM_INPUT_TYPE_SCHEMES); } break; case R.id.list_of_data_types: if (position == DATA_TYPES_LIST.length - 1) { showCustomInputDialog(getString(R.string.data_types_title), CUSTOM_INPUT_TYPE_DATA_TYPES); } break; default: break; } }
Example 12
Source File: EditFilter.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
@Override public void onItemSelected(AdapterView<?> spinner, View arg1, int arg2, long arg3) { int spinnerId = spinner.getId(); if (spinnerId == R.id.filter_action) { int action = Filter.getActionForPosition(actionSpinner.getSelectedItemPosition()) ; if(action == Filter.ACTION_REPLACE || action == Filter.ACTION_AUTO_ANSWER) { replaceContainer.setVisibility(View.VISIBLE); if(action == Filter.ACTION_REPLACE) { replaceSpinner.setVisibility(View.VISIBLE); replaceTextEditor.setHint(""); }else { replaceSpinner.setVisibility(View.GONE); replaceTextEditor.setHint(R.string.optional_sip_code); } }else { replaceContainer.setVisibility(View.GONE); } } else if (spinnerId == R.id.matcher_type) { if(initMatcherSpinner) { matchesTextEditor.setText(""); }else { initMatcherSpinner = true; } } else if (spinnerId == R.id.replace_type) { if(initReplaceSpinner) { replaceTextEditor.setText(""); }else { initReplaceSpinner = true; } } matchesTextEditor.setVisibility(matcherNeedsText() ? View.VISIBLE : View.GONE); checkFormValidity(); }
Example 13
Source File: MainActivity.java From SlideLayout with GNU General Public License v2.0 | 5 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.top_left: sl_top.closeLeftMenu(cb_anim.isChecked()); break; case R.id.top_right: sl_top.closeRightMenu(cb_anim.isChecked()); break; case R.id.top_top: sl_top.closeTopMenu(cb_anim.isChecked()); break; case R.id.top_bottom: sl_top.closeBottomMenu(cb_anim.isChecked()); break; case R.id.bottom_left: sl_bottom.closeLeftMenu(cb_anim.isChecked()); break; case R.id.bottom_right: sl_bottom.closeRightMenu(cb_anim.isChecked()); break; case R.id.bottom_top: sl_bottom.closeTopMenu(cb_anim.isChecked()); break; case R.id.bottom_bottom: sl_bottom.closeBottomMenu(cb_anim.isChecked()); break; } }
Example 14
Source File: CustomizeFragment.java From ListBuddies with Apache License 2.0 | 5 votes |
@Override public void onItemSelected(AdapterView<?> adapterView, View spinner, int position, long id) { int value; switch (adapterView.getId()) { case R.id.fillGapSpinner: mFillGapSpinnerPosition = position; value = mColorSpinnerSections.get(position).getColor(getActivity()); mOnCustomizeListener.setGapColor(value); break; case R.id.autoScrollSpinner: mAutoScrollSpinnerPosition = position; value = mScrollScrollSpinnerSections.get(position).getScrollOption(); mOnCustomizeListener.setAutoScrollFaster(value); break; case R.id.scrollSpinner: mManualScrollSpinnerPosition = position; value = mScrollScrollSpinnerSections.get(position).getScrollOption(); mOnCustomizeListener.setScrollFaster(value); break; case R.id.dividerSpinner: mDividerSpinnerPosition = position; int color = mColorSpinnerSections.get(position).getColor(getActivity()); color = color == ListBuddiesLayout.ATTR_NOT_SET ? getResources().getColor(android.R.color.transparent) : color; Drawable drawable = new ColorDrawable(color); mOnCustomizeListener.setDivider(drawable); break; } }
Example 15
Source File: AmapFragment.java From BmapLite with Apache License 2.0 | 5 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (parent.getId() == R.id.list_floors) { mIndoorInfoAdapter.setCurFloor((String) mIndoorInfoAdapter.getItem(position)); mIndoorInfoAdapter.notifyDataSetChanged(); ((MainActivity) getActivity()).showPoiLay(null, 0); if (null != mIndoorBuildingInfo) { mIndoorBuildingInfo.activeFloorName = mIndoorBuildingInfo.floor_names[position]; mIndoorBuildingInfo.activeFloorIndex = mIndoorBuildingInfo.floor_indexs[position]; mAmap.setIndoorBuildingInfo(mIndoorBuildingInfo); } } }
Example 16
Source File: PlayerControlFragment.java From android-openslmediaplayer with Apache License 2.0 | 5 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.spinner_player_aux_effect_type: postAppEvent( PlayerControlReqEvents.PLAYER_ATTACH_AUX_EFFECT, position, 0); break; } }
Example 17
Source File: SettingsActivity.java From abnd-track-pomodoro-timer-app with MIT License | 5 votes |
/** * Save the latest selected item position from the spinners * into SharedPreferences * * @param parent * @param view * @param position * @param id */ @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // initialize the editor SharedPreferences.Editor editor = preferences.edit(); // switch case to handle different spinners switch (parent.getId()) { // item selected in work duration spinner case R.id.work_duration_spinner: // save the corresponding item position editor.putInt(getString(R.string.work_duration_key), position); break; // item selected in short break duration spinner case R.id.short_break_duration_spinner: // save the corresponding item position editor.putInt(getString(R.string.short_break_duration_key), position); break; // item selected in long break duration spinner case R.id.long_break_duration_spinner: // save the corresponding item position editor.putInt(getString(R.string.long_break_duration_key), position); case R.id.start_long_break_after_spinner: // save the corresponding item position editor.putInt(getString(R.string.start_long_break_after_key), position); } editor.apply(); }
Example 18
Source File: Spinner_Fragment.java From ui with Apache License 2.0 | 5 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent.getId() == R.id.spinner1) { // used to control the seekbar if (position != -1) //-1 is nothing selected. just making sure. mySeekBar.setProgress(position); //just use position, don't care about the text itself themselves. } else { //this case, I want the text in the spinner box. Toast.makeText(myContext, parent.getAdapter().getItem(position).toString(), Toast.LENGTH_LONG).show(); } }
Example 19
Source File: MainActivity.java From NotificationDemo with Apache License 2.0 | 4 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.sp_priority: mBuilder.setPriority(position - 2); break; case R.id.sp_buttons: mBuilder.mActions.clear(); if (position == 1) { mBuilder.addAction(android.R.drawable.ic_media_play, "Play", pi(1001)); } else if (position == 2) { mBuilder.addAction(android.R.drawable.ic_media_previous, "Prev", pi(1001)); mBuilder.addAction(android.R.drawable.ic_media_next, "Next", pi(1002)); } else if (position == 3) { mBuilder.addAction(android.R.drawable.ic_media_previous, "Prev", pi(1001)); mBuilder.addAction(android.R.drawable.ic_media_play, "Play", pi(1002)); mBuilder.addAction(android.R.drawable.ic_media_next, "Next", pi(1003)); } break; case R.id.sp_progress: if (position == 0) { mBuilder.setProgress(0, 0, false); } else { mBuilder.setProgress(100, 50, position == 2); } break; case R.id.sp_style: if (position == 0) { mBuilder.setStyle(null); } else if (position == 1) { mBuilder.setStyle(NotifyUtil.makeBigText("big text content\nbig text content\nbig text content\nbig text content\nbig text " + "content\nbig text content\n") .setBigContentTitle("big text title") .setSummaryText("big text summary")); } else if (position == 2) { Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.photo480); mBuilder.setStyle(NotifyUtil.makeBigPicture(bitmap).setBigContentTitle("big text title").setSummaryText("big text summary")); } else if (position == 3) { List<String> messages = Arrays.asList(new String[]{"line 1", "line 2", "line 3"}); mBuilder.setStyle(NotifyUtil.makeInbox(messages).setBigContentTitle("big text title").setSummaryText("big text summary")); } break; case R.id.sp_time: if (position == 0) { mBuilder.setShowWhen(false); mBuilder.setUsesChronometer(false); } else if (position == 1) { mBuilder.setShowWhen(true); mBuilder.setUsesChronometer(false); } else if (position == 2) { mBuilder.setShowWhen(true); mBuilder.setUsesChronometer(true); } break; case R.id.sp_alert: mBuilder.setDefaults(DEFAULTS[position]); break; case R.id.sp_visibility: mBuilder.setVisibility(position - 1); break; case R.id.sp_category: mBuilder.setCategory(parent.getSelectedItem().toString()); break; } }
Example 20
Source File: CircleProgressBarActivity.java From ProjectX with Apache License 2.0 | 4 votes |
@SuppressLint("RtlHardcoded") @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.cpb_sp_gravity: switch (position) { default: case 0: mProgress.setGravity(Gravity.CENTER); break; case 1: mProgress.setGravity(Gravity.LEFT); break; case 2: mProgress.setGravity(Gravity.CENTER_HORIZONTAL); break; case 3: mProgress.setGravity(Gravity.RIGHT); break; case 4: mProgress.setGravity(Gravity.CENTER_VERTICAL); break; case 5: mProgress.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT); break; case 6: mProgress.setGravity(Gravity.BOTTOM); break; case 7: mProgress.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); break; case 8: mProgress.setGravity(Gravity.BOTTOM | Gravity.RIGHT); break; } break; case R.id.cpb_sp_scale_type: switch (position) { default: case 0: mProgress.setScaleType(CircleProgressBar.ST_INSIDE); break; case 1: mProgress.setScaleType(CircleProgressBar.ST_CROP); break; case 2: mProgress.setScaleType( CircleProgressBar.ST_INSIDE | CircleProgressBar.ST_CROP); break; case 3: mProgress.setScaleType(CircleProgressBar.ST_NONE); break; } break; case R.id.cpb_sp_dial_visibility: switch (position) { default: case 0: mProgress.setDialVisibility(View.VISIBLE); break; case 1: mProgress.setDialVisibility(View.INVISIBLE); break; case 2: mProgress.setDialVisibility(View.GONE); break; } break; case R.id.cpb_sp_dial_gravity: switch (position) { default: case 0: mProgress.setDialGravity(Gravity.CENTER); break; case 1: mProgress.setDialGravity(Gravity.TOP); break; case 2: mProgress.setDialGravity(Gravity.BOTTOM); break; } break; } }