List of usage examples for android.widget RadioButton setOnCheckedChangeListener
public void setOnCheckedChangeListener(@Nullable OnCheckedChangeListener listener)
From source file:org.anhonesteffort.flock.SelectServiceProviderFragment.java
private void initRadioButtons(View fragmentView) { final LinearLayout rowSelectOws = (LinearLayout) fragmentView.findViewById(R.id.row_service_ows); final LinearLayout rowSelectOther = (LinearLayout) fragmentView.findViewById(R.id.row_service_other); final RadioButton radioButtonOws = (RadioButton) fragmentView.findViewById(R.id.radio_button_service_ows); final RadioButton radioButtonOther = (RadioButton) fragmentView .findViewById(R.id.radio_button_service_other); final TextView serviceDescription = (TextView) fragmentView.findViewById(R.id.sync_service_description); final Double costPerYearUsd = (double) getResources().getInteger(R.integer.cost_per_year_usd); rowSelectOws.setOnClickListener(new View.OnClickListener() { @Override/* www. j av a 2s. c o m*/ public void onClick(View view) { if (!radioButtonOws.isChecked()) { radioButtonOws.setChecked(true); radioButtonOther.setChecked(false); serviceDescription.setText(Html.fromHtml( getString(R.string.flock_sync_is_a_service_run_by_open_whisper_systems_available, costPerYearUsd))); serviceDescription.setMovementMethod(LinkMovementMethod.getInstance()); } } }); rowSelectOther.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!radioButtonOther.isChecked()) { radioButtonOther.setChecked(true); radioButtonOws.setChecked(false); serviceDescription .setText(R.string.you_may_chose_to_run_and_configure_your_own_webdav_compliant_server); } } }); radioButtonOws.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { if (isChecked) { radioButtonOws.setChecked(true); radioButtonOther.setChecked(false); serviceDescription.setText(Html.fromHtml( getString(R.string.flock_sync_is_a_service_run_by_open_whisper_systems_available, costPerYearUsd))); serviceDescription.setMovementMethod(LinkMovementMethod.getInstance()); } } }); radioButtonOther.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { if (isChecked) { radioButtonOther.setChecked(true); radioButtonOws.setChecked(false); serviceDescription .setText(R.string.you_may_chose_to_run_and_configure_your_own_webdav_compliant_server); } } }); }
From source file:com.rsmsa.accapp.ScreenSlidePageFragmentTwo.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.vehicle_two, container, false); tab_one = (EditText) rootView.findViewById(R.id.dob_one); vehicle_category = (Spinner) rootView.findViewById(R.id.vtype_spinner); vehicle_type = (Button) rootView.findViewById(R.id.vehicle_type_select_button); /**//from w ww . j a v a2 s . c o m * Defining all layout items **/ inputFatal = (EditText) rootView.findViewById(R.id.fatal_edit); inputInjuries = (EditText) rootView.findViewById(R.id.injury_edit); inputSimple = (EditText) rootView.findViewById(R.id.simple_edit); inputNotInjured = (EditText) rootView.findViewById(R.id.not_injured_edit); //driver 0ne details surname_one = (EditText) rootView.findViewById(R.id.surname_one); othernames_one = (EditText) rootView.findViewById(R.id.othernames_one); physical_address_one = (EditText) rootView.findViewById(R.id.physical_address_one); address_box_one = (EditText) rootView.findViewById(R.id.address_box_one); national_id_one = (EditText) rootView.findViewById(R.id.national_id_one); phone_no_one = (EditText) rootView.findViewById(R.id.phone_no_one); final RadioButton male = (RadioButton) rootView.findViewById(R.id.male); final RadioButton female = (RadioButton) rootView.findViewById(R.id.female); nationality_one = (EditText) rootView.findViewById(R.id.nationality_one); license_one = (EditText) rootView.findViewById(R.id.license_one); occupation_one = (EditText) rootView.findViewById(R.id.occupation_one); alcohol_edit = (EditText) rootView.findViewById(R.id.alcohol_edit); drug = (CheckBox) rootView.findViewById(R.id.drug_edit); phone_use = (CheckBox) rootView.findViewById(R.id.phone_edit); seat_belt = (CheckBox) rootView.findViewById(R.id.seat_belt_edit); //Vehicle one details type_one = (EditText) rootView.findViewById(R.id.type_one); registration_number_one = (EditText) rootView.findViewById(R.id.registration_number_one); //Vehicle one Insurance details company_one = (EditText) rootView.findViewById(R.id.company_one); insurance_type_one = (EditText) rootView.findViewById(R.id.insurance_type_one); insurance_phone = (EditText) rootView.findViewById(R.id.insurance_phone); policy_period_one = (EditText) rootView.findViewById(R.id.policy_period_one); policy_number_one = (EditText) rootView.findViewById(R.id.policy_number_one); repair_amount_one = (EditText) rootView.findViewById(R.id.repair_amount_one); //Vehicle one damage details vehicle = (EditText) rootView.findViewById(R.id.vehicle_title_edit); vehicle_total = (EditText) rootView.findViewById(R.id.vehicle_total_edit); infrastructure = (EditText) rootView.findViewById(R.id.infrastructure_edit); cost = (EditText) rootView.findViewById(R.id.rescue_cost_edit); /** * getting values of our view elements */ drug.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { MainActivity.V2_drug_edit = "Drugs Use"; } else { MainActivity.V2_drug_edit = " No Drug use"; } } }); phone_use.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { MainActivity.V2_phone_edit = "Was using Phone"; } else { MainActivity.V2_phone_edit = " No phone use"; } } }); seat_belt.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { MainActivity.V2_seat_belt_edit = "Seat belt not fastened"; } else { MainActivity.V2_seat_belt_edit = "Seat belt fastened"; } } }); male.setChecked(true); // Fatal.setChecked(true); male.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { female.setChecked(false); MainActivity.V2_gender = "male"; } } }); female.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { male.setChecked(false); MainActivity.V2_gender = "female"; } } }); cal = Calendar.getInstance(); day = cal.get(Calendar.DAY_OF_MONTH); month = cal.get(Calendar.MONTH); year = cal.get(Calendar.YEAR); pickDate = (Button) rootView.findViewById(R.id.date_picker); pickDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), datePickerListener, year, month, day); datePickerDialog.show(); } }); List<String> vehicle_category_list = new ArrayList<String>(); vehicle_category_list.add("Private"); vehicle_category_list.add("Commercial"); vehicle_category_list.add("Government"); vehicle_category_list.add("Emergency"); vehicle_category_list.add("Passenger Service Vehicles"); vehicle_category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { selectedSpinner = i; } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); vehicle_type.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getActivity(), VehicleType.class); intent.putExtra("category", selectedSpinner + ""); startActivity(intent); } }); ArrayAdapter<String> atc_adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, vehicle_category_list); atc_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); vehicle_category.setAdapter(atc_adapter); return rootView; }