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:com.ubuntuone.android.files.fragment.AutoUploadSetupFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_autoupload_setup, container, false); mController = (Controller) getActivity(); mRadioGroup = (RadioGroup) view.findViewById(R.id.auto_upload_mode); mContentScroll = (ScrollView) view.findViewById(R.id.content_scroll); mMobileNotice = (TextView) view.findViewById(R.id.auto_upload_mobile_notice); mDoneButton = (Button) view.findViewById(R.id.button_setup_done); mDoneButton.setOnClickListener(this); final RadioGroup autoUploadMode = (RadioGroup) view.findViewById(R.id.auto_upload_mode); autoUploadMode.setOnCheckedChangeListener(this); selectInitialAutoUploadMode(autoUploadMode); return view;//from w w w . jav a 2s.co m }
From source file:org.howto.usesupportlibrary.v7.CardViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.card_view_activity); mInfoText = (TextView) findViewById(R.id.info_text); mCardView = (CardView) findViewById(R.id.card_view); mCornerRadiusSeekBar = (SeekBar) findViewById(R.id.corner_radius_seek_bar); mCornerRadiusSeekBar.setProgress((int) mCardView.getRadius()); mCornerRadiusSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); mWidthSeekBar = (SeekBar) findViewById(R.id.width_seek_bar); mWidthSeekBar.setProgress(mCardView.getLayoutParams().width); mWidthSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); mHeightSeekBar = (SeekBar) findViewById(R.id.height_seek_bar); mHeightSeekBar.setProgress(mCardView.getLayoutParams().height); mHeightSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); mElevationSeekBar = (SeekBar) findViewById(R.id.elevation_seek_bar); mElevationSeekBar.setProgress((int) mCardView.getCardElevation()); mElevationSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); mMaxElevationSeekBar = (SeekBar) findViewById(R.id.max_elevation_seek_bar); mMaxElevationSeekBar.setProgress((int) mCardView.getMaxCardElevation()); mMaxElevationSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); mAlphaSeekBar = (SeekBar) findViewById(R.id.alpha_seek_bar); mAlphaSeekBar.setProgress((int) ViewCompat.getAlpha(mCardView) * 255); mAlphaSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); RadioGroup rb = (RadioGroup) findViewById(R.id.select_target_radio); rb.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override//w ww .j a v a 2 s . com public void onCheckedChanged(RadioGroup group, int checkedId) { mResizeCardView = checkedId == R.id.resize_card_view; update(); } }); update(); new Handler().postDelayed(new Runnable() { @Override public void run() { View content = findViewById(android.R.id.content); mWidthSeekBar.setMax(content.getWidth()); mHeightSeekBar.setMax(content.getHeight()); } }, 100); }
From source file:com.example.android.support.design.widget.TabLayoutPreselectedUsage.java
private void setupRadioGroup() { // Setup the initially checked item switch (mTabLayout.getTabMode()) { case TabLayout.MODE_SCROLLABLE: ((RadioButton) findViewById(R.id.rb_tab_scrollable)).setChecked(true); break;/*from w w w . ja v a 2 s .c o m*/ case TabLayout.MODE_FIXED: ((RadioButton) findViewById(R.id.rb_tab_fixed)).setChecked(true); break; } RadioGroup rg = (RadioGroup) findViewById(R.id.radiogroup_tab_mode); rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int id) { switch (id) { case R.id.rb_tab_fixed: mTabLayout.setTabMode(TabLayout.MODE_FIXED); break; case R.id.rb_tab_scrollable: mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); break; } } }); // Setup the initially checked item switch (mTabLayout.getTabGravity()) { case TabLayout.GRAVITY_CENTER: ((RadioButton) findViewById(R.id.rb_tab_g_center)).setChecked(true); break; case TabLayout.GRAVITY_FILL: ((RadioButton) findViewById(R.id.rb_tab_g_fill)).setChecked(true); break; } rg = (RadioGroup) findViewById(R.id.radiogroup_tab_gravity); rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int id) { switch (id) { case R.id.rb_tab_g_center: mTabLayout.setTabGravity(TabLayout.GRAVITY_CENTER); break; case R.id.rb_tab_g_fill: mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL); break; } } }); }
From source file:com.example.android.supportv7.view.CardViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_card_view); mInfoText = (TextView) findViewById(R.id.info_text); mCardView = (CardView) findViewById(R.id.card_view); mCornerRadiusSeekBar = (SeekBar) findViewById(R.id.corner_radius_seek_bar); mCornerRadiusSeekBar.setProgress((int) mCardView.getRadius()); mCornerRadiusSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); mWidthSeekBar = (SeekBar) findViewById(R.id.width_seek_bar); mWidthSeekBar.setProgress(mCardView.getLayoutParams().width); mWidthSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); mHeightSeekBar = (SeekBar) findViewById(R.id.height_seek_bar); mHeightSeekBar.setProgress(mCardView.getLayoutParams().height); mHeightSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); mElevationSeekBar = (SeekBar) findViewById(R.id.elevation_seek_bar); mElevationSeekBar.setProgress((int) mCardView.getCardElevation()); mElevationSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); mMaxElevationSeekBar = (SeekBar) findViewById(R.id.max_elevation_seek_bar); mMaxElevationSeekBar.setProgress((int) mCardView.getMaxCardElevation()); mMaxElevationSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); mAlphaSeekBar = (SeekBar) findViewById(R.id.alpha_seek_bar); mAlphaSeekBar.setProgress((int) ViewCompat.getAlpha(mCardView) * 255); mAlphaSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener); RadioGroup rb = (RadioGroup) findViewById(R.id.select_target_radio); rb.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override/*w ww . j av a 2s. c om*/ public void onCheckedChanged(RadioGroup group, int checkedId) { mResizeCardView = checkedId == R.id.resize_card_view; update(); } }); new Handler().postDelayed(new Runnable() { @Override public void run() { View content = findViewById(android.R.id.content); mWidthSeekBar.setProgress(mCardView.getWidth()); mHeightSeekBar.setProgress(mCardView.getHeight()); mWidthSeekBar.setMax(content.getWidth()); mHeightSeekBar.setMax(content.getHeight()); update(); } }, 100); ((RadioGroup) findViewById(R.id.select_bg_color_radio)) .setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { mCardView.setCardBackgroundColor(getResources().getColor(getColorId(checkedId))); } }); }
From source file:com.loadsensing.app.Chart.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.chart);//from ww w . ja v a 2s.c o m final WebView googleChartView = (WebView) findViewById(R.id.chart); Bundle extras = null; if (savedInstanceState == null) { extras = getIntent().getExtras(); if (extras == null) { SensorSelected = null; } else { SensorSelected = extras.getString("idsensorselected"); Log.d(DEB_TAG, "Xarxa que hem triat anteriorment: " + SensorSelected); } } // Listener para generar el grfico cada vez que se escoge la opcin en // el radiobutton RadioGroup rg = (RadioGroup) findViewById(R.id.tipochart); rg.clearCheck(); rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { generaChart(googleChartView, checkedId, SensorSelected); } }); }
From source file:fi.tuukka.weather.view.FragmentStations.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.asemat, container, false); rg = (RadioGroup) view.findViewById(R.id.radioGroup1); rg.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override/*from www . j av a 2 s. c om*/ public void onCheckedChanged(RadioGroup rg, int id) { if (listenCheck) { for (int i = 0; i < rg.getChildCount(); i++) { RadioButton btn = (RadioButton) rg.getChildAt(i); if (btn.getId() == id) { String text = (String) btn.getText(); Station station = new Station(text, null); changeStation(station); refreshStations(); return; } } } } }); EditText searchBox = (EditText) view.findViewById(R.id.stationSearchBox); searchBox.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String string = s.toString(); if (query == null || !query.equals(string)) { query = s.toString(); stationStrings = null; // mark as not finished ((ActivityMain) getActivity()).queryStations(); } } }); Activity activity = getActivity(); header = (TextView) view.findViewById(R.id.stationsHeader); int fontsize = Utils.getScaledFont(activity); int pad = Utils.dpToPx(5, activity); header.setTextAppearance(activity, R.style.TextStyle); header.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontsize); header.setPadding(0, pad, 0, pad); header.setText("Syt kunta/kunnanosa:"); super.onCreateView(inflater, container, savedInstanceState); return view; }
From source file:com.kyakujin.android.autoeco.ui.SyncSettingFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mActivity = getActivity();//from w ww .java2 s . c o m LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.fragment_dialog_setting_sync, null, false); RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroupSync); // ????????? radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.radioSyncOn: mEnabled = true; break; case R.id.radioSyncOff: mEnabled = false; break; default: mEnabled = false; } } }); mCurrentEcoId = getArguments().getInt(Conf.SHARED_ECOID); mEnabled = getArguments().getInt(Conf.SHARED_SYNC_ENABLED) == 1 ? true : false; // ? setDefaultRadioButton(radioGroup); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.setting_sync); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { EcoDAO dao = new EcoDAO(mActivity); dao.updateSyncEnabled(mCurrentEcoId, mEnabled); } }); builder.setNegativeButton("Cancel", null); builder.setView(view); return builder.create(); }
From source file:com.kyakujin.android.autoeco.ui.WifiSettingFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mActivity = getActivity();/*from w ww .j a va 2s .c o m*/ LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.fragment_dialog_setting_wifi, null, false); RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroupWifi); // ????????? radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.radioWifiOn: mEnabled = true; break; case R.id.radioWifiOff: mEnabled = false; break; default: mEnabled = false; } } }); mCurrentEcoId = getArguments().getInt(Conf.SHARED_ECOID); mEnabled = getArguments().getInt(Conf.SHARED_WIFI_ENABLED) == 1 ? true : false; // ? setDefaultRadioButton(radioGroup); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.setting_wifi); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { EcoDAO dao = new EcoDAO(mActivity); dao.updateWifiEnabled(mCurrentEcoId, mEnabled); } }); builder.setNegativeButton("Cancel", null); builder.setView(view); return builder.create(); }
From source file:com.kyakujin.android.autoeco.ui.RotateSettingFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mActivity = getActivity();//from w ww. j a va 2 s .co m LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.fragment_dialog_setting_rotate, null, false); RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroupRotate); // ????????? radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { // ??????? public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.radioRotateOn: mEnabled = true; break; case R.id.radioRotateOff: mEnabled = false; break; default: mEnabled = false; } } }); mCurrentEcoId = getArguments().getInt(Conf.SHARED_ECOID); mEnabled = getArguments().getInt(Conf.SHARED_ROTATE_ENABLED) == 1 ? true : false; // ? setDefaultRadioButton(radioGroup); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.setting_rotate); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { EcoDAO dao = new EcoDAO(mActivity); dao.updateRotateEnabled(mCurrentEcoId, mEnabled); } }); builder.setNegativeButton("Cancel", null); builder.setView(view); return builder.create(); }
From source file:com.kyakujin.android.autoeco.ui.BluetoothSettingFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mActivity = getActivity();/*from w w w . ja v a2 s. c o m*/ LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.fragment_dialog_setting_bluetooth, null, false); RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroupBluetooth); // ????????? radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { // ?????? public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.radioBluetoothOn: mEnabled = true; break; case R.id.radioBluetoothOff: mEnabled = false; break; default: mEnabled = false; } } }); mCurrentEcoId = getArguments().getInt(Conf.SHARED_ECOID); mEnabled = getArguments().getInt(Conf.SHARED_BLUETOOTH_ENABLED) == 1 ? true : false; // ? setDefaultRadioButton(radioGroup); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.setting_bluetooth); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { EcoDAO dao = new EcoDAO(mActivity); dao.updateBluetoothEnabled(mCurrentEcoId, mEnabled); } }); builder.setNegativeButton("Cancel", null); builder.setView(view); return builder.create(); }