Example usage for android.widget RadioButton setChecked

List of usage examples for android.widget RadioButton setChecked

Introduction

In this page you can find the example usage for android.widget RadioButton setChecked.

Prototype

@Override
public void setChecked(boolean checked) 

Source Link

Document

Changes the checked state of this button.

Usage

From source file:com.vkassin.mtrade.Common.java

public static void putOrder(final Context ctx, Quote quote) {

    final Instrument it = Common.selectedInstrument;// adapter.getItem(selectedRowId);

    final Dialog dialog = new Dialog(ctx);
    dialog.setContentView(R.layout.order_dialog);
    dialog.setTitle(R.string.OrderDialogTitle);

    datetxt = (EditText) dialog.findViewById(R.id.expdateedit);
    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
    Date dat1 = new Date();
    datetxt.setText(sdf.format(dat1));// w  ww.j  av a 2s.  co  m
    mYear = dat1.getYear() + 1900;
    mMonth = dat1.getMonth();
    mDay = dat1.getDate();
    final Date dat = new GregorianCalendar(mYear, mMonth, mDay).getTime();

    datetxt.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.i(TAG, "Show DatePickerDialog");
            DatePickerDialog dpd = new DatePickerDialog(ctx, mDateSetListener, mYear, mMonth, mDay);
            dpd.show();
        }
    });

    TextView itext = (TextView) dialog.findViewById(R.id.instrtext);
    itext.setText(it.symbol);

    final Spinner aspinner = (Spinner) dialog.findViewById(R.id.acc_spinner);
    List<String> list = new ArrayList<String>(Common.getAccountList());
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(Common.app_ctx,
            android.R.layout.simple_spinner_item, list);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
    aspinner.setAdapter(dataAdapter);

    final EditText pricetxt = (EditText) dialog.findViewById(R.id.priceedit);
    final EditText quanttxt = (EditText) dialog.findViewById(R.id.quantedit);

    final Button buttonpm = (Button) dialog.findViewById(R.id.buttonPriceMinus);
    buttonpm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                double price = Double.valueOf(pricetxt.getText().toString());
                price -= 0.01;
                if (price < 0)
                    price = 0;
                pricetxt.setText(twoDForm.format(price));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonpp = (Button) dialog.findViewById(R.id.buttonPricePlus);
    buttonpp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                double price = Double.valueOf(pricetxt.getText().toString());
                price += 0.01;
                pricetxt.setText(twoDForm.format(price));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonqm = (Button) dialog.findViewById(R.id.buttonQtyMinus);
    buttonqm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                long qty = Long.valueOf(quanttxt.getText().toString());
                qty -= 1;
                if (qty < 0)
                    qty = 0;
                quanttxt.setText(String.valueOf(qty));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonqp = (Button) dialog.findViewById(R.id.buttonQtyPlus);
    buttonqp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                long qty = Long.valueOf(quanttxt.getText().toString());
                qty += 1;
                quanttxt.setText(String.valueOf(qty));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final RadioButton bu0 = (RadioButton) dialog.findViewById(R.id.radio0);
    final RadioButton bu1 = (RadioButton) dialog.findViewById(R.id.radio1);

    if (quote != null) {

        // pricetxt.setText(quote.price.toString());
        pricetxt.setText(quote.getPriceS());
        if (quote.qtyBuy > 0) {

            quanttxt.setText(quote.qtyBuy.toString());
            bu1.setChecked(true);
            bu0.setChecked(false);

        } else {

            quanttxt.setText(quote.qtySell.toString());
            bu1.setChecked(false);
            bu0.setChecked(true);

        }
    }

    Button customDialog_Cancel = (Button) dialog.findViewById(R.id.cancelbutt);
    customDialog_Cancel.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            dialog.dismiss();
        }

    });

    Button customDialog_Put = (Button) dialog.findViewById(R.id.putorder);
    customDialog_Put.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            Double price = new Double(0);
            Long qval = new Long(0);

            try {

                price = Double.valueOf(pricetxt.getText().toString());
            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
                return;
            }
            try {

                qval = Long.valueOf(quanttxt.getText().toString());
            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
                return;
            }

            if (dat.compareTo(new GregorianCalendar(mYear, mMonth, mDay).getTime()) > 0) {

                Toast.makeText(ctx, R.string.CorrectDate, Toast.LENGTH_SHORT).show();

                return;

            }

            JSONObject msg = new JSONObject();
            try {

                msg.put("objType", Common.CREATE_REMOVE_ORDER);
                msg.put("time", Calendar.getInstance().getTimeInMillis());
                msg.put("version", Common.PROTOCOL_VERSION);
                msg.put("device", "Android");
                msg.put("instrumId", Long.valueOf(it.id));
                msg.put("price", price);
                msg.put("qty", qval);
                msg.put("ordType", 1);
                msg.put("side", bu0.isChecked() ? 0 : 1);
                msg.put("code", String.valueOf(aspinner.getSelectedItem()));
                msg.put("orderNum", ++ordernum);
                msg.put("action", "CREATE");
                boolean b = (((mYear - 1900) == dat.getYear()) && (mMonth == dat.getMonth())
                        && (mDay == dat.getDate()));
                if (!b)
                    msg.put("expired", String.format("%02d.%02d.%04d", mDay, mMonth + 1, mYear));

                if (isSSL) {

                    //                ? ?:    newOrder-orderNum-instrumId-side-price-qty-code-ordType
                    //               :                  newOrder-16807-20594623-0-1150-13-1027700451-1
                    String forsign = "newOrder-" + ordernum + "-" + msg.getString("instrumId") + "-"
                            + msg.getString("side") + "-"
                            + JSONObject.numberToString(Double.valueOf(msg.getDouble("price"))) + "-"
                            + msg.getString("qty") + "-" + msg.getString("code") + "-"
                            + msg.getString("ordType");
                    byte[] signed = Common.signText(Common.signProfile, forsign.getBytes(), true);
                    String gsign = Base64.encodeToString(signed, Base64.DEFAULT);
                    msg.put("gostSign", gsign);
                }
                mainActivity.writeJSONMsg(msg);

            } catch (Exception e) {

                e.printStackTrace();
                Log.e(TAG, "Error! Cannot create JSON order object", e);
            }

            dialog.dismiss();
        }

    });

    dialog.show();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.FILL_PARENT;
    dialog.getWindow().setAttributes(lp);

}

From source file:com.trimph.toprand.trimphrxandroid.trimph.ui.main.news.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof RadioButton) {

            RadioButton tab = (RadioButton) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            //                tab.setTypeface(tabTypeface, tabTypefaceStyle);
            //                tab.setTextColor(getContext().getResources().getColor(R.drawable.common_tab_strip_text_selector));
            //                tab.setTextColor(Color.parseColor("#303f9f"));

            if (i == currentPosition) {
                tab.setChecked(true);
            } else {
                tab.setChecked(false);//from w  w w . java  2s .c o m
            }

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:com.RSMSA.policeApp.Fragments.PaymentVerifierFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    contentView = (RelativeLayout) inflater.inflate(R.layout.fragment_payment_verifier, container, false);
    /**//from   w w w  .j  a v  a2 s.com
     * get the instances of the buttons at our view
     */

    progressBar = (ProgressBar) contentView.findViewById(R.id.pbar_main);

    inputnformation = (RelativeLayout) contentView.findViewById(R.id.input_information);
    verificationResults = (ScrollView) contentView.findViewById(R.id.verification_results);
    driversOffenceList = (LinearLayout) contentView.findViewById(R.id.history_list_driver);
    vehiclesOffenceList = (LinearLayout) contentView.findViewById(R.id.history_list_car);
    vehiclesDetails = (LinearLayout) contentView.findViewById(R.id.vehicles_details);
    driversDetails = (LinearLayout) contentView.findViewById(R.id.drivers_details);

    nameTextView = (TextView) contentView.findViewById(R.id.name);
    licenseNumberTextView = (TextView) contentView.findViewById(R.id.license_number);
    addressTextView = (TextView) contentView.findViewById(R.id.address);
    genderTextView = (TextView) contentView.findViewById(R.id.gender);
    dateOfBirthTextView = (TextView) contentView.findViewById(R.id.date_of_birth);
    phoneNumberTextView = (TextView) contentView.findViewById(R.id.phone_number);
    makeTextView = (TextView) contentView.findViewById(R.id.make);

    plateNumberTextView = (TextView) contentView.findViewById(R.id.plate_number);
    typeTextView = (TextView) contentView.findViewById(R.id.type);
    colorTextView = (TextView) contentView.findViewById(R.id.color);

    scanBtn = (ImageView) contentView.findViewById(R.id.scan_button);
    verifyBtn = (Button) contentView.findViewById(R.id.verify);
    verifyBtn.setTypeface(MainOffence.Rosario_Bold);

    licenseEdittext = (EditText) contentView.findViewById(R.id.license_);

    verifyBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.d("MainOffense", "verify button clicked");
            licenceNumber = licenseEdittext.getText().toString();

            if (licenceNumber.equals("")) {
                Toast toast = Toast.makeText(getActivity(), " Field Empty!", Toast.LENGTH_SHORT);
                toast.show();
            } else {
                verifyBtn.setVisibility(View.INVISIBLE);
                progressBar.setVisibility(View.VISIBLE);
                progressBar.bringToFront();
                NetAsync(view);

            }
        }
    });

    final RadioButton licence = (RadioButton) contentView.findViewById(R.id.licence);
    licence.setTypeface(MainOffence.Roboto_Regular);
    final RadioButton plate = (RadioButton) contentView.findViewById(R.id.plate);
    plate.setTypeface(MainOffence.Roboto_Regular);

    licence.setChecked(true);

    licence.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                driversPaymentVerification = true;
                licenseEdittext.setHint("Enter Licence No");
            }
        }
    });

    plate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                driversPaymentVerification = false;
                licenseEdittext.setHint("Enter Plate No");
            }
        }
    });

    try {
        receivedNumber = getArguments().getString("licenceNumber");
    } catch (Exception e) {
    }

    if (receivedNumber != null) {
        verifyLicenceNumber(receivedNumber);
    } else {
        try {
            receivedNumber = getArguments().getString("plateNumber");
        } catch (Exception e) {
        }

        if (!receivedNumber.equals("") || receivedNumber != null) {
            driversPaymentVerification = false;
            plate.setChecked(true);
            licence.setChecked(false);
            verifyLicenceNumber(receivedNumber);
        }
    }

    return contentView;

}

From source file:com.frostwire.android.gui.fragments.BrowsePeerFragment.java

private RadioButton initRadioButton(View v, int viewId, final byte fileType) {
    RadioButton button = findView(v, viewId);
    Resources r = button.getResources();
    FileTypeRadioButtonSelectorFactory fileTypeRadioButtonSelectorFactory = new FileTypeRadioButtonSelectorFactory(
            fileType, r, FileTypeRadioButtonSelectorFactory.RadioButtonContainerType.BROWSE);
    fileTypeRadioButtonSelectorFactory.updateButtonBackground(button);
    button.setClickable(true);// w w  w . j av a 2  s .  c  o  m
    RadioButtonListener rbListener = new RadioButtonListener(button, fileType,
            fileTypeRadioButtonSelectorFactory);
    button.setOnClickListener(rbListener);
    button.setOnCheckedChangeListener(rbListener);
    button.setChecked(fileType == Constants.FILE_TYPE_AUDIO);
    radioButtonFileTypeMap.put(fileType, button);
    return button;
}

From source file:com.bonsai.wallet32.SendBitcoinActivity.java

private void addAccountRow(TableLayout table, int acctId, String acctName, long btc, double fiat) {
    TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.send_from_row, table, false);

    RadioButton tv0 = (RadioButton) row.findViewById(R.id.from_account);
    tv0.setId(acctId); // Change id to the acctId.
    tv0.setText(acctName);/*from   www.  j  a  v a2 s  . c o  m*/
    tv0.setOnCheckedChangeListener(mSendFromListener);
    if (acctId == mCheckedFromId)
        tv0.setChecked(true);

    TextView tv1 = (TextView) row.findViewById(R.id.row_btc);
    tv1.setText(String.format("%s", mBTCFmt.formatCol(btc, 0, true, true)));

    TextView tv2 = (TextView) row.findViewById(R.id.row_fiat);
    tv2.setText(String.format("%.02f", fiat));

    table.addView(row);
}

From source file:de.Maxr1998.xposed.maxlock.ui.settings.appslist.AppListAdapter.java

@Override
public void onBindViewHolder(final AppsListViewHolder hld, final int position) {
    final String sTitle = (String) mItemList.get(position).get("title");
    final String key = (String) mItemList.get(position).get("key");
    final Drawable dIcon = (Drawable) mItemList.get(position).get("icon");

    hld.appName.setText(sTitle);//from w  ww  .ja v a 2  s .c o  m
    hld.appIcon.setImageDrawable(dIcon);

    if (prefsPackages.getBoolean(key, false)) {
        hld.toggle.setChecked(true);
        hld.options.setVisibility(View.VISIBLE);
    } else {
        hld.toggle.setChecked(false);
        hld.options.setVisibility(View.GONE);
    }

    hld.appIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (key.equals("com.android.packageinstaller"))
                return;
            Intent it = mContext.getPackageManager().getLaunchIntentForPackage(key);
            it.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(it);
        }
    });

    hld.options.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // AlertDialog View
            // Fake die checkbox
            View checkBoxView = View.inflate(mContext, R.layout.per_app_settings, null);
            CheckBox fakeDie = (CheckBox) checkBoxView.findViewById(R.id.cb_fake_die);
            fakeDie.setChecked(prefsPackages.getBoolean(key + "_fake", false));
            fakeDie.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    CheckBox cb = (CheckBox) v;
                    boolean value = cb.isChecked();
                    prefsPackages.edit().putBoolean(key + "_fake", value).commit();
                }
            });
            // Custom password checkbox
            CheckBox customPassword = (CheckBox) checkBoxView.findViewById(R.id.cb_custom_pw);
            customPassword.setChecked(prefsPerApp.contains(key));
            customPassword.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    CheckBox cb = (CheckBox) v;
                    boolean checked = cb.isChecked();
                    if (checked) {
                        dialog.dismiss();
                        final AlertDialog.Builder choose_lock = new AlertDialog.Builder(mContext);
                        CharSequence[] cs = new CharSequence[] {
                                mContext.getString(R.string.pref_locking_type_password),
                                mContext.getString(R.string.pref_locking_type_pin),
                                mContext.getString(R.string.pref_locking_type_knockcode),
                                mContext.getString(R.string.pref_locking_type_pattern) };
                        choose_lock.setItems(cs, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                dialogInterface.dismiss();
                                Fragment frag = new Fragment();
                                switch (i) {
                                case 0:
                                    Util.setPassword(mContext, key);
                                    break;
                                case 1:
                                    frag = new PinSetupFragment();
                                    break;
                                case 2:
                                    frag = new KnockCodeSetupFragment();
                                    break;
                                case 3:
                                    Intent intent = new Intent(LockPatternActivity.ACTION_CREATE_PATTERN, null,
                                            mContext, LockPatternActivity.class);
                                    mFragment.startActivityForResult(intent, Util.getPatternCode(position));
                                    break;
                                }
                                if (i == 1 || i == 2) {
                                    Bundle b = new Bundle(1);
                                    b.putString(Common.INTENT_EXTRAS_CUSTOM_APP, key);
                                    frag.setArguments(b);
                                    ((SettingsActivity) mContext).getSupportFragmentManager().beginTransaction()
                                            .replace(R.id.frame_container, frag).addToBackStack(null).commit();
                                }
                            }
                        }).show();
                    } else
                        prefsPerApp.edit().remove(key).remove(key + Common.APP_KEY_PREFERENCE).apply();

                }
            });
            // Finish dialog
            dialog = new AlertDialog.Builder(mContext)
                    .setTitle(mContext.getString(R.string.dialog_title_settings)).setIcon(dIcon)
                    .setView(checkBoxView)
                    .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dlg, int id) {
                            dlg.dismiss();
                        }
                    }).setNeutralButton(R.string.dialog_button_exclude_activities,
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    new ActivityLoader().execute(key);
                                }
                            })
                    .show();
        }
    });
    hld.toggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            RadioButton rb = (RadioButton) v;
            boolean value = prefsPackages.getBoolean(key, false);

            if (!value) {
                prefsPackages.edit().putBoolean(key, true).commit();
                AnimationSet anim = new AnimationSet(true);
                anim.addAnimation(AnimationUtils.loadAnimation(mContext, R.anim.appslist_settings_rotate));
                anim.addAnimation(AnimationUtils.loadAnimation(mContext, R.anim.appslist_settings_translate));
                hld.options.startAnimation(anim);
                hld.options.setVisibility(View.VISIBLE);
                rb.setChecked(true);
            } else {
                prefsPackages.edit().remove(key).commit();
                rb.setChecked(true);

                AnimationSet animOut = new AnimationSet(true);
                animOut.addAnimation(
                        AnimationUtils.loadAnimation(mContext, R.anim.appslist_settings_rotate_out));
                animOut.addAnimation(
                        AnimationUtils.loadAnimation(mContext, R.anim.appslist_settings_translate_out));
                animOut.setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {

                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, 0.0f);
                        animation.setDuration(1);
                        hld.options.startAnimation(animation);
                        hld.options.setVisibility(View.GONE);
                        hld.options.clearAnimation();
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {

                    }
                });
                hld.options.startAnimation(animOut);
            }

            notifyDataSetChanged();
        }

    });
}

From source file:com.RSMSA.policeApp.OffenceReportForm.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_report_offence);
    sharedpreferences = getSharedPreferences(MyPREF, Context.MODE_PRIVATE);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from   w  w  w .  ja v  a2s.c o  m

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setTranslucentStatus(true);
    }
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    tintManager.setStatusBarTintEnabled(true);
    ColorDrawable colorDrawable = new ColorDrawable(getResources().getColor(R.color.blue_900));
    tintManager.setTintDrawable(colorDrawable);

    RelativeLayout inputs = (RelativeLayout) findViewById(R.id.inputs);
    plateNumberEdit = (EditText) findViewById(R.id.plate_number_edit_text);
    licenceNumberEdit = (EditText) findViewById(R.id.licence_number_edit_text);

    final Bundle bundle = getIntent().getExtras();
    namePassed = bundle.getString("name");
    dLicense = bundle.getString("licence_number");
    plateNumberObtained = bundle.getString("plate_number");
    driverUid = bundle.getString("driverUid");
    vehicleUid = bundle.getString("vehicleUid");

    try {
        invalidLicence = bundle.getString("invalidLicence");
        expiredInsuarance = bundle.getString("expiredInsuarance");
    } catch (NullPointerException e) {
    }

    if (dLicense.equals("") || dLicense == null) {
        licenceNumberEdit.setVisibility(View.VISIBLE);
    } else if (plateNumberObtained.equals("") || plateNumberObtained == null) {
        plateNumberEdit.setVisibility(View.VISIBLE);
    }

    submit = (TextView) findViewById(R.id.submit_text);

    plateNo = (TextView) findViewById(R.id.plate_no_);
    chargesAcceptance = (TextView) findViewById(R.id.charges_acceptance);
    chargesAcceptance.setTypeface(MainOffence.Roboto_Regular);

    offensesCommittedTextview = (TextView) findViewById(R.id.offences_committed_title);
    offensesCommittedTextview.setTypeface(MainOffence.Roboto_BoldCondensed);

    ChargesAcceptanceTitle = (TextView) findViewById(R.id.charges_acceptance_title);
    paymentMethodTitle = (TextView) findViewById(R.id.payment_method_title);
    PaymentTitle = (TextView) findViewById(R.id.payment_title);

    ChargesAcceptanceTitle.setTypeface(MainOffence.Roboto_BoldCondensed);
    paymentMethodTitle.setTypeface(MainOffence.Roboto_BoldCondensed);
    PaymentTitle.setTypeface(MainOffence.Roboto_BoldCondensed);

    offencesCostTitle = (TextView) findViewById(R.id.offences_cost_title);
    offencesCostTitle.setTypeface(MainOffence.Roboto_BoldCondensed);

    submitText = (TextView) findViewById(R.id.submit_text);

    license = (TextView) findViewById(R.id.license);
    license.setText(dLicense);

    report = (RelativeLayout) findViewById(R.id.report);
    summary = (RelativeLayout) findViewById(R.id.summary);
    submit_layout = (RelativeLayout) findViewById(R.id.submit_layout);

    submit_layout1 = (RelativeLayout) findViewById(R.id.submit_layout1);
    submit_layout1.setVisibility(View.GONE);

    progressBar = (ProgressBar) findViewById(R.id.pbar_report);

    TextView driverName = (TextView) findViewById(R.id.driver_name);
    driverName.setTypeface(MainOffence.Roboto_BoldCondensed);

    TextView plateNumberTitle = (TextView) findViewById(R.id.plate_no_title_);
    plateNumberTitle.setTypeface(MainOffence.Roboto_BoldCondensed);

    TextView driverLicense = (TextView) findViewById(R.id.driver_license);
    driverLicense.setTypeface(MainOffence.Roboto_BoldCondensed);

    RelativeLayout OffenseType = (RelativeLayout) findViewById(R.id.offense_type);
    OffenseType.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(OffenceReportForm.this, OffenseListActivity.class);
            OffenceReportForm.this.startActivityForResult(intent, REPORT_RESULT);
        }
    });

    offense_type_text = (TextView) findViewById(R.id.offense_type_text);

    offencesSelectedTextView = (TextView) findViewById(R.id.offence_list);
    offensesCommittedTextview = (TextView) findViewById(R.id.offences_committed);

    TextView name = (TextView) findViewById(R.id.name);
    name.setText(namePassed);

    final RadioButton court = (RadioButton) findViewById(R.id.court);
    court.setTypeface(MainOffence.Roboto_BoldCondensed);
    final RadioButton guilty = (RadioButton) findViewById(R.id.guilty);
    guilty.setTypeface(MainOffence.Roboto_BoldCondensed);

    guilty.setChecked(true);

    court.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                guilty.setChecked(false);
                commit = false;
            }
        }
    });

    guilty.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                court.setChecked(false);
                commit = true;
            }
        }
    });

    final String[] paymentMethodsArray = this.getResources().getStringArray(R.array.payment_methods);
    final Spinner paymentMethodSpinner = (Spinner) findViewById(R.id.payment_method_spinner);
    final RadioButton paid = (RadioButton) findViewById(R.id.paid);
    paid.setTypeface(MainOffence.Roboto_Regular);
    final RadioButton not_paid = (RadioButton) findViewById(R.id.not_paid);
    final TextView receipt_title = (TextView) findViewById(R.id.receipt_title);
    receiptEditText = (EditText) findViewById(R.id.receipt);

    receipt_title.setTypeface(MainOffence.Roboto_BoldCondensed);

    not_paid.setTypeface(MainOffence.Roboto_Regular);

    not_paid.setChecked(true);

    paymentMethodSpinner.setBackground(null);

    paid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                paymentStatus = true;
                paymentMethodTitle.setVisibility(View.VISIBLE);
                paymentMethodSpinner.setVisibility(View.VISIBLE);
                paymentMethod = paymentMethodsArray[0];
                paymentMethodSpinner.setSelection(0);
                receipt_title.setVisibility(View.VISIBLE);
                receiptEditText.setVisibility(View.VISIBLE);
            }
        }
    });

    not_paid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                paymentStatus = false;
                paymentMethodTitle.setVisibility(View.GONE);
                paymentMethodSpinner.setVisibility(View.GONE);
                receipt_title.setVisibility(View.GONE);
                receiptEditText.setVisibility(View.GONE);
                paymentMethod = "";
                receiptEditText.setText("");

            }
        }
    });

    PaymentMethodSpinnerAdapter adapter = new PaymentMethodSpinnerAdapter(
            getSupportActionBar().getThemedContext(), R.layout.row_menu, paymentMethodsArray);
    paymentMethodSpinner.setAdapter(adapter);
    paymentMethodSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            paymentMethod = paymentMethodsArray[position];
            if (position == 0) {
                receiptEditText.setVisibility(View.VISIBLE);
                receipt_title.setVisibility(View.VISIBLE);
            } else {
                receiptEditText.setVisibility(View.GONE);
                receipt_title.setVisibility(View.GONE);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

}

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

/**
 * RadioButtons on FlashAs Layout/*from w  w  w  . j  ava  2s  .c  o  m*/
 */
public void FlashAsOpt(View view) {
    if (view.getTag().toString().equals("recovery")) {
        RadioButton optAsKernel = (RadioButton) findViewById(R.id.optAsKernel);
        optAsKernel.setChecked(false);
    } else {
        RadioButton optAsRecovery = (RadioButton) findViewById(R.id.optAsRecovery);
        optAsRecovery.setChecked(false);
    }
    findViewById(R.id.bFlashAs).setEnabled(true);
}

From source file:org.openmrs.mobile.activities.formdisplay.FormDisplayPageFragment.java

@Override
public void createAndAttachSelectQuestionRadioButton(Question question, LinearLayout sectionLinearLayout) {
    TextView textView = new TextView(getActivity());
    textView.setPadding(20, 0, 0, 0);/*from w w w .j  a va2s  .c o  m*/
    textView.setText(question.getLabel());

    RadioGroup radioGroup = new RadioGroup(getActivity());

    for (Answer answer : question.getQuestionOptions().getAnswers()) {
        RadioButton radioButton = new RadioButton(getActivity());
        radioButton.setText(answer.getLabel());
        radioGroup.addView(radioButton);
    }

    SelectOneField radioGroupField = new SelectOneField(question.getQuestionOptions().getAnswers(),
            question.getQuestionOptions().getConcept());

    LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    sectionLinearLayout.addView(textView);
    sectionLinearLayout.addView(radioGroup);

    sectionLinearLayout.setLayoutParams(linearLayoutParams);

    SelectOneField selectOneField = getSelectOneField(radioGroupField.getConcept());
    if (selectOneField != null) {
        if (selectOneField.getChosenAnswerPosition() != -1) {
            RadioButton radioButton = (RadioButton) radioGroup
                    .getChildAt(selectOneField.getChosenAnswerPosition());
            radioButton.setChecked(true);
        }
        setOnCheckedChangeListener(radioGroup, selectOneField);
    } else {
        setOnCheckedChangeListener(radioGroup, radioGroupField);
        selectOneFields.add(radioGroupField);
    }
}

From source file:net.sylvek.sharemyposition.ShareMyPosition.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    default:/*www .j  a  va  2 s.c om*/
        return super.onCreateDialog(id);
    case MAP_DLG:
        final View sharedMapView = LayoutInflater.from(this).inflate(R.layout.sharedmap, null);
        final FrameLayout map = (FrameLayout) sharedMapView.findViewById(R.id.sharedmap);
        map.addView(this.sharedMap);
        final CheckBox latlonAddress = (CheckBox) sharedMapView.findViewById(R.id.add_lat_lon_location);
        final CheckBox geocodeAddress = (CheckBox) sharedMapView.findViewById(R.id.add_address_location);
        final RadioButton nourl = (RadioButton) sharedMapView.findViewById(R.id.add_no_url_location);
        final RadioButton url = (RadioButton) sharedMapView.findViewById(R.id.add_url_location);
        final RadioButton gmap = (RadioButton) sharedMapView.findViewById(R.id.add_native_location);
        final EditText body = (EditText) sharedMapView.findViewById(R.id.body);
        final ToggleButton track = (ToggleButton) sharedMapView.findViewById(R.id.add_track_location);

        latlonAddress.setChecked(pref.getBoolean(PREF_LAT_LON_CHECKED, true));
        geocodeAddress.setChecked(pref.getBoolean(PREF_ADDRESS_CHECKED, true));
        final boolean isUrl = pref.getBoolean(PREF_URL_CHECKED, true);
        final boolean isGmap = pref.getBoolean(PREF_GMAP_CHECKED, false);
        url.setChecked(isUrl);
        gmap.setChecked(isGmap);
        nourl.setChecked(!isUrl && !isGmap);
        body.setText(pref.getString(PREF_BODY_DEFAULT, getString(R.string.body)));
        track.setChecked(pref.getBoolean(PREF_TRACK_CHECKED, false));

        if (track.isChecked()) {
            latlonAddress.setEnabled(false);
            latlonAddress.setChecked(false);
            geocodeAddress.setEnabled(false);
            geocodeAddress.setChecked(false);
            url.setEnabled(false);
            url.setChecked(true);
            gmap.setEnabled(false);
            gmap.setChecked(false);
            nourl.setEnabled(false);
            nourl.setChecked(false);
        }

        track.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                latlonAddress.setEnabled(!isChecked);
                latlonAddress.setChecked(!isChecked);
                geocodeAddress.setEnabled(!isChecked);
                geocodeAddress.setChecked(!isChecked);
                url.setEnabled(!isChecked);
                url.setChecked(true);
                gmap.setEnabled(!isChecked);
                gmap.setChecked(!isChecked);
                nourl.setEnabled(!isChecked);
                nourl.setChecked(!isChecked);
            }
        });

        return new AlertDialog.Builder(this).setTitle(R.string.app_name).setView(sharedMapView)
                .setOnCancelListener(new OnCancelListener() {

                    @Override
                    public void onCancel(DialogInterface arg0) {
                        finish();
                    }
                }).setNeutralButton(R.string.options, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        /* needed to display neutral button */
                    }
                }).setPositiveButton(R.string.share_it, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        final boolean isLatLong = ((CheckBox) sharedMapView
                                .findViewById(R.id.add_lat_lon_location)).isChecked();
                        final boolean isGeocodeAddress = ((CheckBox) sharedMapView
                                .findViewById(R.id.add_address_location)).isChecked();
                        final boolean isUrl = ((RadioButton) sharedMapView.findViewById(R.id.add_url_location))
                                .isChecked();
                        final boolean isGmap = ((RadioButton) sharedMapView
                                .findViewById(R.id.add_native_location)).isChecked();
                        final EditText body = (EditText) sharedMapView.findViewById(R.id.body);
                        final boolean isTracked = ((ToggleButton) sharedMapView
                                .findViewById(R.id.add_track_location)).isChecked();
                        final String uuid = UUID.randomUUID().toString();

                        pref.edit().putBoolean(PREF_LAT_LON_CHECKED, isLatLong)
                                .putBoolean(PREF_ADDRESS_CHECKED, isGeocodeAddress)
                                .putBoolean(PREF_URL_CHECKED, isUrl).putBoolean(PREF_GMAP_CHECKED, isGmap)
                                .putString(PREF_BODY_DEFAULT, body.getText().toString())
                                .putBoolean(PREF_TRACK_CHECKED, isTracked).commit();

                        final Intent t = new Intent(Intent.ACTION_SEND);
                        t.setType("text/plain");
                        t.addCategory(Intent.CATEGORY_DEFAULT);
                        final Intent share = Intent.createChooser(t, getString(R.string.app_name));
                        final GeoPoint p = sharedMap.getMapCenter();

                        final String text = body.getText().toString();
                        share(p.getLatitude(), p.getLongitude(), t, share, text, isGeocodeAddress, isUrl,
                                isGmap, isLatLong, isTracked, uuid);
                    }
                }).create();
    case PROGRESS_DLG:
        final ProgressDialog dlg = new ProgressDialog(this);
        dlg.setTitle(getText(R.string.app_name));
        dlg.setMessage(getText(R.string.progression_desc));
        dlg.setIndeterminate(true);
        dlg.setCancelable(true);
        dlg.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
        return dlg;
    case PROVIDERS_DLG:
        return new AlertDialog.Builder(this).setTitle(R.string.app_name).setCancelable(false)
                .setIcon(android.R.drawable.ic_menu_help).setMessage(R.string.providers_needed)
                .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }

                }).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent gpsProperty = new Intent(
                                android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivity(gpsProperty);
                    }
                }).create();
    }
}