List of usage examples for android.widget RadioGroup setOnCheckedChangeListener
public void setOnCheckedChangeListener(OnCheckedChangeListener listener)
Register a callback to be invoked when the checked radio button changes in this group.
From source file:Main.java
public static final RadioGroup initRadioGroup(View view, int resourceId, RadioGroup.OnCheckedChangeListener listener) { RadioGroup ret = null; ret = findRadioGroupX(view, resourceId); ret.setOnCheckedChangeListener(listener); return ret;//from w w w. j a v a 2s . c om }
From source file:it.cosenonjaviste.twowaydatabinding.DataBindingConverters.java
@BindingAdapter({ "app:binding" }) public static void bindRadioGroup(RadioGroup view, final ObservableString observableString) { if (view.getTag(R.id.bound_observable) != observableString) { view.setTag(R.id.bound_observable, observableString); view.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override// w w w . ja v a 2s. c o m public void onCheckedChanged(RadioGroup group, int checkedId) { for (int i = 0; i < group.getChildCount(); i++) { final View child = group.getChildAt(i); if (checkedId == child.getId()) { observableString.set(child.getTag().toString()); break; } } } }); } String newValue = observableString.get(); for (int i = 0; i < view.getChildCount(); i++) { final View child = view.getChildAt(i); if (child.getTag().toString().equals(newValue)) { ((RadioButton) child).setChecked(true); break; } } }
From source file:com.luksprog.playground.fragment.SimpleCABFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); RadioGroup rg = (RadioGroup) getView().findViewById(R.id.radioGroup1); rg.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override/* w w w . j a va2 s .co m*/ public void onCheckedChanged(RadioGroup group, int checkedId) { if (POST_HONEYCOMB) { // this could be improved so we don't need to create the // option // menu if it is already available getActivity().startActionMode(SimpleCABFragment.this); } else { // something else } } }); }
From source file:com.example.android.supportv4.graphics.DrawableCompatActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawable_compat); mImageView = (ImageView) findViewById(R.id.image); Drawable d = ContextCompat.getDrawable(this, IMAGE_RES); mDrawable = DrawableCompat.wrap(d.mutate()); mImageView.setImageDrawable(mDrawable); RadioGroup rg = (RadioGroup) findViewById(R.id.drawable_compat_options); rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override/*w ww . jav a 2 s . c o m*/ public void onCheckedChanged(RadioGroup radioGroup, int id) { switch (id) { case R.id.drawable_compat_no_tint: clearTint(); break; case R.id.drawable_compat_color: setColorTint(); break; case R.id.drawable_compat_state_list: setColorStateListTint(); break; } } }); }
From source file:com.groksolutions.grok.mobile.SortBarFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RadioGroup sortBar = (RadioGroup) inflater.inflate(R.layout.fragment_sort_bar, container, false); sortBar.setOnCheckedChangeListener(this); return sortBar; }
From source file:org.ayo.robot.anim.transitioneverywhere.ScenesSample.java
@Nullable @Override//from w w w . j a v a2 s . co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_scenes, container, false); RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene); radioGroup.setOnCheckedChangeListener(this); mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root); // A Scene can be instantiated from a live view hierarchy. mScene1 = new Scene(mSceneRoot, mSceneRoot.findViewById(R.id.container)); // You can also inflate a generate a Scene from a layout resource file. mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, getContext()); // Another scene from a layout resource file. mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene3, getContext()); // We create a custom TransitionManager for Scene 3, in which ChangeBounds, Fade and // ChangeImageTransform take place at the same time. mTransitionManagerForScene3 = TransitionInflater.from(getContext()) .inflateTransitionManager(R.anim.scene3_transition_manager, mSceneRoot); return view; }
From source file:info.ipeanut.googletrainingcoursedemos.basictransition.BasicTransitionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_basic_transition, container, false); assert view != null; RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene); radioGroup.setOnCheckedChangeListener(this); mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root); // A Scene can be instantiated from a live view hierarchy. mScene1 = new Scene(mSceneRoot, (ViewGroup) mSceneRoot.findViewById(R.id.container)); // You can also inflate a generate a Scene from a layout resource file. mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene_b2, getActivity()); // Another scene from a layout resource file. mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene_b3, getActivity()); // We create a custom TransitionManager for Scene 3, in which ChangeBounds and Fade // take place at the same time. mTransitionManagerForScene3 = TransitionInflater.from(getActivity()) .inflateTransitionManager(R.transition.scene3_transition_manager, mSceneRoot); return view;// w ww. j av a 2 s. c om }
From source file:com.example.android.basictransition.BasicTransitionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_basic_transition, container, false); assert view != null; RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene); radioGroup.setOnCheckedChangeListener(this); mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root); // BEGIN_INCLUDE(instantiation_from_view) // A Scene can be instantiated from a live view hierarchy. mScene1 = new Scene(mSceneRoot, (ViewGroup) mSceneRoot.findViewById(R.id.container)); // END_INCLUDE(instantiation_from_view) // BEGIN_INCLUDE(instantiation_from_resource) // You can also inflate a generate a Scene from a layout resource file. mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, getActivity()); // END_INCLUDE(instantiation_from_resource) // Another scene from a layout resource file. mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene3, getActivity()); // BEGIN_INCLUDE(custom_transition_manager) // We create a custom TransitionManager for Scene 3, in which ChangeBounds and Fade // take place at the same time. mTransitionManagerForScene3 = TransitionInflater.from(getActivity()) .inflateTransitionManager(R.transition.scene3_transition_manager, mSceneRoot); // END_INCLUDE(custom_transition_manager) return view;/*from w w w .j a v a2s.c o m*/ }
From source file:com.example.st.animsharedemo.transitions.BasicTransitionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_basic_transition, container, false); assert view != null; RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene); radioGroup.setOnCheckedChangeListener(this); mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root); // BEGIN_INCLUDE(instantiation_from_view) // A Scene can be instantiated from a live view hierarchy. mScene1 = new Scene(mSceneRoot, (ViewGroup) mSceneRoot.findViewById(R.id.container)); // END_INCLUDE(instantiation_from_view) // BEGIN_INCLUDE(instantiation_from_resource) // You can also inflate a generate a Scene from a layout resource file. mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene22, getActivity()); // END_INCLUDE(instantiation_from_resource) // Another scene from a layout resource file. mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene33, getActivity()); // BEGIN_INCLUDE(custom_transition_manager) // We create a custom TransitionManager for Scene 3, in which ChangeBounds and Fade // take place at the same time. mTransitionManagerForScene3 = TransitionInflater.from(getActivity()) .inflateTransitionManager(R.transition.scene3_transition_manager, mSceneRoot); // END_INCLUDE(custom_transition_manager) return view;//w w w. j a v a 2 s . c om }
From source file:com.example.tripi.transitionanimation.BasicTransitionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_basic_transition, container, false); assert view != null; RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene); radioGroup.setOnCheckedChangeListener(this); mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root); // BEGIN_INCLUDE(instantiation_from_view) // A Scene can be instantiated from a live view hierarchy. mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene1, getActivity()); // mScene1 = new Scene(mSceneRoot, (ViewGroup) mSceneRoot.findViewById(R.id.container)); // END_INCLUDE(instantiation_from_view) // BEGIN_INCLUDE(instantiation_from_resource) // You can also inflate a generate a Scene from a layout resource file. mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, getActivity()); // END_INCLUDE(instantiation_from_resource) // Another scene from a layout resource file. mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene3, getActivity()); // BEGIN_INCLUDE(custom_transition_manager) // We create a custom TransitionManager for Scene 3, in which ChangeBounds and Fade // take place at the same time. mTransitionManagerForScene3 = TransitionInflater.from(getActivity()) .inflateTransitionManager(R.transition.scene3_transition_manager, mSceneRoot); mTransitionManagerForScene2 = TransitionInflater.from(getActivity()) .inflateTransitionManager(R.transition.scene2_transition_manager, mSceneRoot); mTransitionManagerForScene1 = TransitionInflater.from(getActivity()) .inflateTransitionManager(R.transition.scene1_transition_manager, mSceneRoot); // END_INCLUDE(custom_transition_manager) return view;//from w w w . j av a 2 s . c o m }