List of usage examples for android.widget RadioButton isChecked
@ViewDebug.ExportedProperty @Override public boolean isChecked()
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
/** * Creates open311 question and answer attributes to submit a report * Reads from dynamically created UI/* w w w. j a v a2s .c om*/ * * @param serviceDescription contains attribute types * @return List of code value pair of attributes */ private List<Open311AttributePair> createOpen311Attributes(ServiceDescription serviceDescription) { List<Open311AttributePair> attributes = new ArrayList<>(); for (Open311Attribute open311Attribute : serviceDescription.getAttributes()) { if (Boolean.valueOf(open311Attribute.getVariable())) { if (Open311DataType.STRING.equals(open311Attribute.getDatatype()) || Open311DataType.NUMBER.equals(open311Attribute.getDatatype()) || Open311DataType.DATETIME.equals(open311Attribute.getDatatype())) { EditText et = (EditText) mDynamicAttributeUIMap.get(open311Attribute.getCode()); if (et != null) { attributes.add(new Open311AttributePair(open311Attribute.getCode(), et.getText().toString(), open311Attribute.getDatatype())); } } else if (Open311DataType.SINGLEVALUELIST.equals(open311Attribute.getDatatype())) { RadioGroup rg = (RadioGroup) mDynamicAttributeUIMap.get(open311Attribute.getCode()); if (rg != null) { int count = rg.getChildCount(); for (int i = 0; i < count; i++) { RadioButton rb = (RadioButton) rg.getChildAt(i); if (rb.isChecked()) { String attributeKey = mOpen311AttributeKeyNameMap .get(open311Attribute.getCode() + rb.getText().toString()); attributes.add(new Open311AttributePair(open311Attribute.getCode(), attributeKey, open311Attribute.getDatatype())); break; } } } } else if (Open311DataType.MULTIVALUELIST.equals(open311Attribute.getDatatype())) { LinearLayout ll = (LinearLayout) mDynamicAttributeUIMap.get(open311Attribute.getCode()); if (ll != null) { int count = ll.getChildCount(); for (int i = 0; i < count; i++) { CheckBox cb = (CheckBox) ll.getChildAt(i); if (cb.isChecked()) { String attributeKey = mOpen311AttributeKeyNameMap .get(open311Attribute.getCode() + cb.getText().toString()); attributes.add(new Open311AttributePair(open311Attribute.getCode(), attributeKey, open311Attribute.getDatatype())); } } } } } } return attributes; }
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
/** * This method dynamically reads all user inputted the values from the screen and puts into a * list// w w w .j a v a 2s . c o m * * @param serviceDescription displayed service description * @return List of attribute values */ private List<AttributeValue> createAttributeValues(ServiceDescription serviceDescription) { List<AttributeValue> values = new ArrayList<>(); if (serviceDescription == null) { return values; } for (Open311Attribute open311Attribute : serviceDescription.getAttributes()) { if (Boolean.valueOf(open311Attribute.getVariable())) { if (Open311DataType.STRING.equals(open311Attribute.getDatatype()) || Open311DataType.NUMBER.equals(open311Attribute.getDatatype()) || Open311DataType.DATETIME.equals(open311Attribute.getDatatype())) { EditText et = (EditText) mDynamicAttributeUIMap.get(open311Attribute.getCode()); if (et != null) { AttributeValue value = new AttributeValue(open311Attribute.getCode()); value.addValue(et.getText().toString()); values.add(value); } } else if (Open311DataType.SINGLEVALUELIST.equals(open311Attribute.getDatatype())) { RadioGroup rg = (RadioGroup) mDynamicAttributeUIMap.get(open311Attribute.getCode()); if (rg != null) { int count = rg.getChildCount(); for (int i = 0; i < count; i++) { RadioButton rb = (RadioButton) rg.getChildAt(i); if (rb.isChecked()) { AttributeValue value = new AttributeValue(open311Attribute.getCode()); value.addValue(rb.getText().toString()); values.add(value); break; } } } } else if (Open311DataType.MULTIVALUELIST.equals(open311Attribute.getDatatype())) { LinearLayout ll = (LinearLayout) mDynamicAttributeUIMap.get(open311Attribute.getCode()); if (ll != null) { int count = ll.getChildCount(); AttributeValue value = new AttributeValue(open311Attribute.getCode()); for (int i = 0; i < count; i++) { CheckBox cb = (CheckBox) ll.getChildAt(i); if (cb.isChecked()) { value.addValue(cb.getText().toString()); } } if (value.getValues().size() > 0) values.add(value); } } } } return values; }
From source file:de.mkrtchyan.recoverytools.RecoveryTools.java
public void flashAs(View view) { String path;//from ww w. j av a2 s . c o m keepAppOpen = false; if ((path = getIntent().getData().getPath()) != null) { final File IMG = new File(path); if (IMG.exists()) { RadioButton optAsRecovery = (RadioButton) findViewById(R.id.optAsRecovery); if (optAsRecovery.isChecked()) { fRECOVERY = IMG; rRecoveryFlasher.run(); } else { fKERNEL = IMG; rKernelFlasher.run(); } } else { exit(); } } else { exit(); } }
From source file:transapps.gpxfitness.ui.MainActivity.java
public void profileAlertDialog() { final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.profile_dialog); dialog.setTitle("Please Enter Profile:"); dialog.setCancelable(false);//from w ww . j a v a 2s . c o m Button ok_button = (Button) dialog.findViewById(R.id.button); ok_button.setText("Ok"); final EditText username = (EditText) dialog.findViewById(R.id.username); final EditText height_ft = (EditText) dialog.findViewById(R.id.height_ft); final EditText height_in = (EditText) dialog.findViewById(R.id.height_in); final EditText weight_lbs = (EditText) dialog.findViewById(R.id.weight_lbs); final EditText age_yrs = (EditText) dialog.findViewById(R.id.age_yrs); final RadioButton male = (RadioButton) dialog.findViewById(R.id.male); final EditText[] et = { username, height_ft, height_in, weight_lbs, age_yrs }; ok_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String user_string = username.getText().toString(); String height_ft_string = height_ft.getText().toString(); String height_in_string = height_in.getText().toString(); String weight_lbs_string = weight_lbs.getText().toString(); String age_yrs_string = age_yrs.getText().toString(); boolean are_any_empty = false; for (EditText e : et) { String str = e.getText().toString(); if (str == null || str.length() == 0) are_any_empty = true; } if (!are_any_empty) { int height = Integer.parseInt(height_ft_string) * 12 + Integer.parseInt(height_in_string); String sex; if (male.isChecked()) sex = "male"; else sex = "female"; ProfileAccessor.createNewProfile(user_string, height, Integer.parseInt(weight_lbs_string), sex, Integer.parseInt(age_yrs_string)); dialog.dismiss(); } } }); dialog.show(); }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display dialog to allow user to add an app to a row. The user can add the * app to an existing row or a new row.//w w w. j a v a2s .c o m * * @param context * @param applications */ public static void displayAddApps(final Launcher context, final ArrayList<ApplicationInfo> applications) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.add_apps_grid); final EditText nameEditText = (EditText) dialog.findViewById(R.id.rowName); final RadioButton currentRadioButton = (RadioButton) dialog.findViewById(R.id.currentRadio); currentRadioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // hide the row name edit field if the current row radio button // is selected nameEditText.setVisibility(View.GONE); } }); final RadioButton newRadioButton = (RadioButton) dialog.findViewById(R.id.newRadio); newRadioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // show the row name edit field if the new radio button is // selected nameEditText.setVisibility(View.VISIBLE); nameEditText.requestFocus(); } }); final GridView gridView = (GridView) dialog.findViewById(R.id.grid); gridView.setAdapter(new AllItemAdapter(context, getApplications(context, applications, true))); gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // if the new row radio button is selected, the user must enter // a name for the new row String name = nameEditText.getText().toString().trim(); if (newRadioButton.isChecked() && name.length() == 0) { nameEditText.requestFocus(); displayAlert(context, context.getString(R.string.dialog_new_row_name_alert)); return; } ItemInfo itemInfo = (ItemInfo) parent.getAdapter().getItem(position); boolean currentRow = !newRadioButton.isChecked(); context.addItem(itemInfo, currentRow ? null : name); context.showCover(false); dialog.dismiss(); if (currentRow) { Analytics.logEvent(Analytics.DIALOG_ADD_APP); } else { Analytics.logEvent(Analytics.ADD_APP_WITH_ROW); } } }); gridView.setDrawingCacheEnabled(true); gridView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_ADD_APP); }
From source file:com.terraremote.terrafieldreport.OpenGroundReport.java
public void highRiskAlert(View v) { RadioButton postHighRisk = findViewById(R.id.postHighRisk); RadioButton postVeryHighRisk = findViewById(R.id.postVeryHighRisk); TextView safetyNotice = findViewById(R.id.safetyNotice); if (postHighRisk.isChecked() || postVeryHighRisk.isChecked()) { safetyNotice.setVisibility(View.VISIBLE); } else {//from w w w.j av a 2 s . c o m safetyNotice.setVisibility(View.GONE); } }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display dialog to the user for the Spotlight web apps: * https://www.google.com/tv/spotlight-gallery.html Allow the user to add a * web app to an existing row or a new row. * /*from ww w . ja v a2 s . c o m*/ * @param context */ public static void displayAddSpotlight(final Launcher context) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.add_apps_grid); final EditText nameEditText = (EditText) dialog.findViewById(R.id.rowName); final RadioButton currentRadioButton = (RadioButton) dialog.findViewById(R.id.currentRadio); currentRadioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // hide the row name edit field if the current row radio button // is selected nameEditText.setVisibility(View.GONE); } }); final RadioButton newRadioButton = (RadioButton) dialog.findViewById(R.id.newRadio); newRadioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // show the row name edit field if the new radio button is // selected nameEditText.setVisibility(View.VISIBLE); nameEditText.requestFocus(); } }); final GridView gridView = (GridView) dialog.findViewById(R.id.grid); final ArrayList<SpotlightInfo> spotlights = SpotlightTable.getAllSpotlights(context); gridView.setAdapter(new AllSpotlightAdapter(context, spotlights)); gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // if the new row radio button is selected, the user must enter // a name for the new row String name = nameEditText.getText().toString().trim(); if (newRadioButton.isChecked() && name.length() == 0) { nameEditText.requestFocus(); displayAlert(context, context.getString(R.string.dialog_new_row_name_alert)); return; } ItemInfo itemInfo = (ItemInfo) parent.getAdapter().getItem(position); boolean currentRow = !newRadioButton.isChecked(); context.addItem(itemInfo, currentRow ? null : name); context.showCover(false); dialog.dismiss(); if (currentRow) { Analytics.logEvent(Analytics.ADD_SPOTLIGHT_WEB_APP); } else { Analytics.logEvent(Analytics.ADD_SPOTLIGHT_WEB_APP_WITH_ROW); } } }); gridView.setDrawingCacheEnabled(true); gridView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_ADD_SPOTLIGHT_WEB_APP); }
From source file:com.example.android.aerotoolbox.MainActivity.java
public void IsentropicCalculate(View view) { int labels[] = { R.id.isentropic_mach_output, R.id.isentropic_pressure_output, R.id.isentropic_temperature_output, R.id.isentropic_density_output, R.id.isentropic_area_output }; int labels2[] = { R.id.isentropic_mach_output2, R.id.isentropic_pressure_output2, R.id.isentropic_temperature_output2, R.id.isentropic_density_output2, R.id.isentropic_area_output2 }; int prefixes[] = { R.string.Mach, R.string.p_ratio, R.string.t_ratio, R.string.rho_ratio, R.string.a_ratio };/*ww w . j a v a 2 s . co m*/ int title = R.id.isentropic_label; int title2 = R.id.isentropic_label2; String message; TextView IsentropicTextView; double M, p_ratio, t_ratio, rho_ratio, a_ratio; RadioButton radio_mach, radio_pressure, radio_temperature, radio_density, radio_area; EditText text; try { radio_mach = (RadioButton) findViewById(R.id.radio_mach); radio_pressure = (RadioButton) findViewById(R.id.radio_pressure); radio_temperature = (RadioButton) findViewById(R.id.radio_temperature); radio_density = (RadioButton) findViewById(R.id.radio_density); radio_area = (RadioButton) findViewById(R.id.radio_area); if (radio_mach.isChecked()) { text = (EditText) findViewById(R.id.isentropic_mach_input); M = Double.parseDouble(text.getText().toString().trim()); t_ratio = 1 / (1 + M * M / 5); p_ratio = Math.pow(t_ratio, 3.5); rho_ratio = p_ratio / t_ratio; a_ratio = 1 / (M * Math.pow(1.2 * t_ratio, 3)); } else if (radio_pressure.isChecked()) { text = (EditText) findViewById(R.id.isentropic_pressure_input); p_ratio = Double.parseDouble(text.getText().toString().trim()); if (p_ratio <= 0 || p_ratio >= 1) { ShowToast("Pressure ratio must be between 0 and 1"); return; } t_ratio = Math.pow(p_ratio, 1 / 3.5); M = Math.sqrt(5 / t_ratio - 5); rho_ratio = p_ratio / t_ratio; a_ratio = 1 / (M * Math.pow(1.2 * t_ratio, 3)); } else if (radio_temperature.isChecked()) { text = (EditText) findViewById(R.id.isentropic_temperature_input); t_ratio = Double.parseDouble(text.getText().toString().trim()); if (t_ratio <= 0 || t_ratio >= 1) { ShowToast("Temperature ratio must be between 0 and 1"); return; } M = Math.sqrt(5 / t_ratio - 5); p_ratio = Math.pow(t_ratio, 3.5); rho_ratio = p_ratio / t_ratio; a_ratio = 1 / (M * Math.pow(1.2 * t_ratio, 3)); } else if (radio_density.isChecked()) { text = (EditText) findViewById(R.id.isentropic_density_input); rho_ratio = Double.parseDouble(text.getText().toString().trim()); if (rho_ratio <= 0 || rho_ratio >= 1) { ShowToast("Density ratio must be between 0 and 1"); return; } t_ratio = Math.pow(rho_ratio, 0.4); p_ratio = t_ratio * rho_ratio; M = Math.sqrt(5 / t_ratio - 5); a_ratio = 1 / (M * Math.pow(1.2 * t_ratio, 3)); } else if (radio_area.isChecked()) { text = (EditText) findViewById(R.id.isentropic_area_input); a_ratio = Double.parseDouble(text.getText().toString().trim()); if (a_ratio == 1) { M = 1; t_ratio = 1 / (1 + M * M / 5); p_ratio = Math.pow(t_ratio, 3.5); rho_ratio = p_ratio / t_ratio; IsentropicClearMessage(labels2, title2); } else if (a_ratio > 1) { double tol = 1e-10; int max_it = 100; M = 0; M = AeroCalc.Isentropic(M, a_ratio, tol, max_it); t_ratio = 1 / (1 + M * M / 5); p_ratio = Math.pow(t_ratio, 3.5); rho_ratio = p_ratio / t_ratio; double M2 = 1000, t_ratio2, p_ratio2, rho_ratio2; M2 = AeroCalc.Isentropic(M2, a_ratio, tol, max_it); t_ratio2 = 1 / (1 + M2 * M2 / 5); p_ratio2 = Math.pow(t_ratio2, 3.5); rho_ratio2 = p_ratio2 / t_ratio2; double values2[] = { M2, p_ratio2, t_ratio2, rho_ratio2, a_ratio }; IsentropicSetMessage(prefixes, labels2, values2, title2); } else { ShowToast("Area ratio must be greater than or equal to 1"); return; } } else { return; } } catch (NumberFormatException e) { return; } double values[] = { M, p_ratio, t_ratio, rho_ratio, a_ratio }; IsentropicSetMessage(prefixes, labels, values, title); if (!radio_area.isChecked()) { IsentropicClearMessage(labels2, title2); } }
From source file:com.pseudosudostudios.jdd.views.Grid.java
/** * Prompts the user and calls loadGame() *///from w w w .j a v a 2s . co m public void makeNewGame() { hasUsed = false; if (tiles != null) for (Tile[] row : tiles) for (Tile t : row) t.setVisibility(View.INVISIBLE); AlertDialog.Builder build = new AlertDialog.Builder(getContext()); build.setTitle("How many colors?").setCancelable(false); View myView = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.number_colors_input, null); final EditText input = (EditText) myView.findViewById(R.id.colorInputET); final RadioButton easy = (RadioButton) myView.findViewById(R.id.easyRB); final RadioButton medium = (RadioButton) myView.findViewById(R.id.mediumRB); final RadioButton hard = (RadioButton) myView.findViewById(R.id.hardRB); build.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Grid.numberOfColors = Integer.parseInt(input.getText().toString()); if (numberOfColors < 2) { numberOfColors = 2; Toast.makeText(getContext(), getContext().getString(R.string.too_few_colors), Toast.LENGTH_SHORT).show(); } if (numberOfColors > TileFactory.colors.length) numberOfColors = TileFactory.colors.length; } catch (NumberFormatException e) { Grid.numberOfColors = 6; } if (easy.isChecked()) setDifficulty(Difficulty.EASY); if (medium.isChecked()) setDifficulty(Difficulty.MEDIUM); if (hard.isChecked()) setDifficulty(Difficulty.HARD); Tile.initPaints(); loadNewGame(); invalidate(); // let it draw! } }).setView(myView).show(); }
From source file:transapps.gpxfitness.ui.MainActivity.java
public void editProfileAlertDialog() { if (!ProfileAccessor.isProfileSet()) { profileAlertDialog();//from w w w . j a v a 2 s. com return; } final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.profile_dialog); dialog.setTitle("Edit Profile:"); dialog.setCancelable(true); Button ok_button = (Button) dialog.findViewById(R.id.button); ok_button.setText("Ok"); final EditText username = (EditText) dialog.findViewById(R.id.username); username.setText(ProfileAccessor.getUsername()); final EditText height_ft = (EditText) dialog.findViewById(R.id.height_ft); height_ft.setText("" + (int) ProfileAccessor.getHeight() / 12); final EditText height_in = (EditText) dialog.findViewById(R.id.height_in); height_in.setText("" + (int) ProfileAccessor.getHeight() % 12); final EditText weight_lbs = (EditText) dialog.findViewById(R.id.weight_lbs); weight_lbs.setText(ProfileAccessor.getWeight() + ""); final EditText age_yrs = (EditText) dialog.findViewById(R.id.age_yrs); age_yrs.setText(ProfileAccessor.getAge() + ""); final RadioButton male = (RadioButton) dialog.findViewById(R.id.male); final RadioButton female = (RadioButton) dialog.findViewById(R.id.female); if (ProfileAccessor.getSex().equals("male")) { male.setChecked(true); female.setChecked(false); } else { male.setChecked(false); female.setChecked(true); } final EditText[] et = { username, height_ft, height_in, weight_lbs, age_yrs }; ok_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String user_string = username.getText().toString(); String height_ft_string = height_ft.getText().toString(); String height_in_string = height_in.getText().toString(); Log.d("TEXT", height_in_string); String weight_lbs_string = weight_lbs.getText().toString(); String age_yrs_string = age_yrs.getText().toString(); boolean are_any_empty = false; for (EditText e : et) { String str = e.getText().toString(); if (str == null || str.length() == 0) are_any_empty = true; } if (!are_any_empty) { int height = Integer.parseInt(height_ft_string) * 12 + Integer.parseInt(height_in_string); String sex; if (male.isChecked()) sex = "male"; else sex = "female"; //ProfileAccessor.createNewProfile(user_string, height, Integer.parseInt(weight_lbs_string), sex, Integer.parseInt(age_yrs_string)); ProfileAccessor.changeUsername(user_string); //actionBar.setTitle(getString(R.string.app_name) + ": " + ProfileAccessor.getUsername()); ProfileAccessor.changeHeight(height); ProfileAccessor.changeWeight(Double.parseDouble(weight_lbs_string)); ProfileAccessor.changeSex(sex); ProfileAccessor.changeAge(Integer.parseInt(age_yrs_string)); dialog.dismiss(); } } }); dialog.show(); }