List of usage examples for android.widget RadioGroup check
public void check(@IdRes int id)
Sets the selection to the radio button whose identifier is passed in parameter.
From source file:universe.constellation.orion.viewer.OrionViewerActivity.java
void updateRotation() { RadioGroup rotationGroup = (RadioGroup) findMyViewById(R.id.rotationGroup); if (rotationGroup != null) { //nook case rotationGroup.check(controller.getRotation() == 0 ? R.id.rotate0 : controller.getRotation() == -1 ? R.id.rotate90 : R.id.rotate270); }//from ww w . j a v a 2 s. c o m ListView list = (ListView) findMyViewById(R.id.rotationList); if (list != null) { int index = getScreenOrientationItemPos(controller.getScreenOrientation()); list.setItemChecked(index, true); list.setSelection(index); } }
From source file:universe.constellation.orion.viewer.OrionViewerActivity.java
public void initRotationScreen() { //if (getDevice() instanceof EdgeDevice) { if (false) {//from www . j a v a2 s . co m final RadioGroup rotationGroup = (RadioGroup) findMyViewById(R.id.rotationGroup); rotationGroup.check(R.id.rotate0); if (Device.Info.NOOK2) { RadioButton r0 = (RadioButton) rotationGroup.findViewById(R.id.rotate0); RadioButton r90 = (RadioButton) rotationGroup.findViewById(R.id.rotate90); RadioButton r270 = (RadioButton) rotationGroup.findViewById(R.id.rotate270); TextView tv = (TextView) findMyViewById(R.id.navigation_title); int color = tv.getTextColors().getDefaultColor(); r0.setTextColor(color); r90.setTextColor(color); r270.setTextColor(color); } getSubscriptionManager().addDocListeners(new DocumentViewAdapter() { @Override public void documentOpened(Controller controller) { updateRotation(); } }); ImageButton apply = (ImageButton) findMyViewById(R.id.rotation_apply); apply.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onApplyAction(true); int id = rotationGroup.getCheckedRadioButtonId(); controller.setRotation(id == R.id.rotate0 ? 0 : id == R.id.rotate90 ? -1 : 1); } }); ListView list = (ListView) findMyViewById(R.id.rotationList); list.setVisibility(View.GONE); } else { RadioGroup rotationGroup = (RadioGroup) findMyViewById(R.id.rotationGroup); rotationGroup.setVisibility(View.GONE); final ListView list = (ListView) findMyViewById(R.id.rotationList); //set choices and replace 0 one with Application Default boolean isLevel9 = getOrionContext().getSdkVersion() >= 9; CharSequence[] values = getResources().getTextArray( isLevel9 ? R.array.screen_orientation_full_desc : R.array.screen_orientation_desc); CharSequence[] newValues = new CharSequence[values.length]; for (int i = 0; i < values.length; i++) { newValues[i] = values[i]; } newValues[0] = getResources().getString(R.string.orientation_default_rotation); list.setAdapter(Device.Info.NOOK2 ? new Nook2ListAdapter(this, android.R.layout.simple_list_item_single_choice, newValues, (TextView) findMyViewById(R.id.navigation_title)) : new ArrayAdapter(this, android.R.layout.simple_list_item_single_choice, newValues)); list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); list.setItemChecked(0, true); list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { public void onItemClick(android.widget.AdapterView parent, View view, int position, long id) { CheckedTextView check = (CheckedTextView) view; check.setChecked(!check.isChecked()); } }); final CharSequence[] ORIENTATION_ARRAY = getResources().getTextArray(R.array.screen_orientation_full); list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { public void onItemClick(android.widget.AdapterView parent, View view, int position, long id) { onApplyAction(true); String orientation = ORIENTATION_ARRAY[position].toString(); controller.changeOrinatation(orientation); } }); ImageButton apply = (ImageButton) findMyViewById(R.id.rotation_apply); apply.setVisibility(View.GONE); // apply.setOnClickListener(new View.OnClickListener() { // public void onClick(View view) { // onApplyAction(true); // } // }); } ImageButton cancel = (ImageButton) findMyViewById(R.id.rotation_close); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onAnimatorCancel(); updateRotation(); } }); }
From source file:com.keysolutions.meteorparties.PartyDetailFragment.java
/** * Updates current RSVP display/*from w w w . j a va2 s. c om*/ * @param rootView root view holding all the fields */ @SuppressLint("NewApi") public void updateMyRsvpDisplay(View rootView) { // add info about my RSVP boolean isLoggedIn = MyDDPState.getInstance().isLoggedIn(); ((View) (rootView.findViewById(R.id.login_for_rsvp))) .setVisibility(isLoggedIn ? View.INVISIBLE : View.VISIBLE); ((View) (rootView.findViewById(R.id.rsvp_buttons))) .setVisibility(isLoggedIn ? View.VISIBLE : View.INVISIBLE); ((View) (rootView.findViewById(R.id.label_my_rsvp))) .setVisibility(isLoggedIn ? View.VISIBLE : View.INVISIBLE); if (isLoggedIn) { RadioGroup rsvpButtons = ((RadioGroup) rootView.findViewById(R.id.rsvp_buttons)); rsvpButtons.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int checkedId) { for (int j = 0; j < radioGroup.getChildCount(); j++) { final ToggleButton view = (ToggleButton) radioGroup.getChildAt(j); view.setChecked(view.getId() == checkedId); } } }); ToggleButton btnYes = ((ToggleButton) rootView.findViewById(R.id.rsvp_yes)); ToggleButton btnNo = ((ToggleButton) rootView.findViewById(R.id.rsvp_no)); ToggleButton btnMaybe = ((ToggleButton) rootView.findViewById(R.id.rsvp_maybe)); OnClickListener toggleListener = new OnClickListener() { @Override public void onClick(View v) { onToggle(v); } }; btnYes.setOnClickListener(toggleListener); btnNo.setOnClickListener(toggleListener); btnMaybe.setOnClickListener(toggleListener); String myRsvp = getMyRsvp(); if (myRsvp != null) { if (myRsvp.equals("yes")) { rsvpButtons.check(R.id.rsvp_yes); } else if (myRsvp.equals("no")) { rsvpButtons.check(R.id.rsvp_no); } else if (myRsvp.equals("maybe")) { rsvpButtons.check(R.id.rsvp_maybe); } } // if we can, add button animation on Yes because it's cool if (android.os.Build.VERSION.SDK_INT > 11) { btnYes.animate().setDuration(200); btnYes.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View button, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { ((ToggleButton) button).animate().setInterpolator(sDecelerator).scaleX(.7f).scaleY(.7f); } else { ((ToggleButton) button).animate().setInterpolator(sOverShooter).scaleX(1f).scaleY(1f); } return false; } }); } } }
From source file:universe.constellation.orion.viewer.OrionViewerActivity.java
public void updatePageLayout() { String walkOrder = controller.getDirection(); int lid = controller.getLayout(); ((RadioGroup) findMyViewById(R.id.layoutGroup)) .check(lid == 0 ? R.id.layout1 : lid == 1 ? R.id.layout2 : R.id.layout3); //((RadioGroup) findMyViewById(R.id.directionGroup)).check(did == 0 ? R.id.direction1 : did == 1 ? R.id.direction2 : R.id.direction3); RadioGroup group = (RadioGroup) findMyViewById(R.id.directionGroup); for (int i = 0; i < group.getChildCount(); i++) { View child = group.getChildAt(i); if (child instanceof universe.constellation.orion.viewer.android.RadioButton) { universe.constellation.orion.viewer.android.RadioButton button = (universe.constellation.orion.viewer.android.RadioButton) child; if (walkOrder.equals(button.getWalkOrder())) { group.check(button.getId()); }/*from www .j a va2 s . c o m*/ } } }
From source file:sliding_tab.SlidingTabs.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public View getView(final int position, View convertView, ViewGroup viewGroup) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.event_attending_list_item, null); TextView name = (TextView) convertView.findViewById(R.id.tv_ea_list_item); final RadioGroup radioGroup = (RadioGroup) convertView.findViewById(R.id.radioGroup); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { ArrayList<String>[] dbResult = Helper.getFriends_From_Event(Event_ID); switch (radioGroup.getCheckedRadioButtonId()) { case R.id.rb_ea_list_yes: { Update_Attending(dbResult, Constants.Yes, position); break; }/*w w w. j a va2 s.co m*/ case R.id.rb_ea_list_maybe: { Update_Attending(dbResult, Constants.Maybe, position); break; } case R.id.rb_ea_list_no: { Update_Attending(dbResult, Constants.No, position); break; } } } }); ArrayList<String>[] dbResult = Helper.getFriends_From_Event(Event_ID); //name.setText(dbResult[1].get(position)); name.setText(Helper.getNickname(dbResult[1].get(position))); switch (dbResult[2].get(position)) { case Constants.Yes: { radioGroup.check(R.id.rb_ea_list_yes); break; } case Constants.Maybe: { radioGroup.check(R.id.rb_ea_list_maybe); break; } case Constants.No: { radioGroup.check(R.id.rb_ea_list_no); break; } default: { break; } } if (!dbResult[1].get(position).equals(Constants.MY_User_ID)) { for (int i = 0; i < radioGroup.getChildCount(); i++) { radioGroup.getChildAt(i).setEnabled(false); } } return convertView; }
From source file:com.google.samples.apps.iosched.videolibrary.VideoLibraryFilteredFragment.java
/** * Generates RadioButton for each item of the {@code values} list and adds them to the * {@code radioGroup}. The item equals to {@code selectedValue} will be checked initially. Items * with special Labels can be added using {@code specialValues}. They will be added on top and * in uppercase characters./*from w w w.j av a 2 s . co m*/ */ private <T extends Comparable> void updateRadioGroup(final RadioGroup radioGroup, List<T> values, T selectedValue, Map<T, String> specialValues) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (radioGroup == null) { return; } // Add special Values to the list List<T> specialItemsList = new ArrayList<>(specialValues.keySet()); Collections.sort(specialItemsList); for (T keys : specialItemsList) { values.add(0, keys); } radioGroup.removeAllViews(); int idCounter = 0; for (final T value : values) { View buttonLayout = inflater.inflate(R.layout.video_library_filter_radio_button, radioGroup, false); final RadioButton button = (RadioButton) buttonLayout.findViewById(R.id.button); radioGroup.addView(buttonLayout); // Set the Label of the Radio Button. TextView text = (TextView) buttonLayout.findViewById(R.id.text); text.setText(specialValues.get(value) == null ? value.toString() : specialValues.get(value)); // We have to give different IDs to all the RadioButtons inside the RadioGroup so that // only one can be checked at a time. button.setId(idCounter); idCounter++; // Trigger a RadioButton click when clicking the Text. text.setOnClickListener(new View.OnClickListener() { @Override @TargetApi(15) public void onClick(View v) { button.callOnClick(); } }); // When Clicking the RadioButton filter when re-filter the videos. button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { radioGroup.check(button.getId()); onVideoFilterChanged(value); } }); if (selectedValue.equals(value)) { radioGroup.check(button.getId()); } } }
From source file:biz.bokhorst.xprivacy.ActivityMain.java
@SuppressLint("InflateParams") private void optionSort() { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.sort, null); final RadioGroup rgSMode = (RadioGroup) view.findViewById(R.id.rgSMode); final CheckBox cbSInvert = (CheckBox) view.findViewById(R.id.cbSInvert); // Initialise controls switch (mSortMode) { case SORT_BY_NAME: rgSMode.check(R.id.rbSName); break;// w w w . jav a 2 s.co m case SORT_BY_UID: rgSMode.check(R.id.rbSUid); break; case SORT_BY_INSTALL_TIME: rgSMode.check(R.id.rbSInstalled); break; case SORT_BY_UPDATE_TIME: rgSMode.check(R.id.rbSUpdated); break; case SORT_BY_MODIFY_TIME: rgSMode.check(R.id.rbSModified); break; case SORT_BY_STATE: rgSMode.check(R.id.rbSState); break; } cbSInvert.setChecked(mSortInvert); // Build dialog AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this); alertDialogBuilder.setTitle(R.string.menu_sort); alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher)); alertDialogBuilder.setView(view); alertDialogBuilder.setPositiveButton(ActivityMain.this.getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (rgSMode.getCheckedRadioButtonId()) { case R.id.rbSName: mSortMode = SORT_BY_NAME; break; case R.id.rbSUid: mSortMode = SORT_BY_UID; break; case R.id.rbSInstalled: mSortMode = SORT_BY_INSTALL_TIME; break; case R.id.rbSUpdated: mSortMode = SORT_BY_UPDATE_TIME; break; case R.id.rbSModified: mSortMode = SORT_BY_MODIFY_TIME; break; case R.id.rbSState: mSortMode = SORT_BY_STATE; break; } mSortInvert = cbSInvert.isChecked(); int userId = Util.getUserId(Process.myUid()); PrivacyManager.setSetting(userId, PrivacyManager.cSettingSortMode, Integer.toString(mSortMode)); PrivacyManager.setSetting(userId, PrivacyManager.cSettingSortInverted, Boolean.toString(mSortInvert)); applySort(); } }); alertDialogBuilder.setNegativeButton(ActivityMain.this.getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing } }); // Show dialog AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:com.wanikani.androidnotifier.ItemsFragment.java
/** * Builds the GUI and create the default item listing. Which is * by item type, sorted by time./*from w w w. j a v a 2 s .c o m*/ * @param inflater the inflater * @param container the parent view * @param savedInstance an (unused) bundle */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { RadioGroup rg; ImageButton btn; View sview; int i; super.onCreateView(inflater, container, bundle); scheduleRefresh(); parent = inflater.inflate(R.layout.items, container, false); lview = (ListView) parent.findViewById(R.id.lv_levels); lview.setAdapter(lad); lview.setOnItemClickListener(lcl); iview = (ListView) parent.findViewById(R.id.lv_items); iview.setAdapter(iad); sview = parent.findViewById(R.id.it_search_win); isd = new ItemSearchDialog(sview, iss, fmap.get(filterType), iad); btn = (ImageButton) parent.findViewById(R.id.btn_item_filter); btn.setOnClickListener(mpl); btn = (ImageButton) parent.findViewById(R.id.btn_item_sort); btn.setOnClickListener(mpl); btn = (ImageButton) parent.findViewById(R.id.btn_item_view); btn.setOnClickListener(mpl); btn = (ImageButton) parent.findViewById(R.id.btn_item_search); btn.setOnClickListener(mpl); rg = (RadioGroup) parent.findViewById(R.id.rg_filter); for (i = 0; i < rg.getChildCount(); i++) rg.getChildAt(i).setOnClickListener(rgl); rg.check(R.id.btn_filter_none); rg = (RadioGroup) parent.findViewById(R.id.rg_order); for (i = 0; i < rg.getChildCount(); i++) rg.getChildAt(i).setOnClickListener(rgl); rg.check(R.id.btn_sort_type); enableSorting(true, true, true, true); return parent; }