Example usage for android.widget RadioButton isChecked

List of usage examples for android.widget RadioButton isChecked

Introduction

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

Prototype

@ViewDebug.ExportedProperty
    @Override
    public boolean isChecked() 

Source Link

Usage

From source file:es.uniovi.imovil.fcrtrainer.NetworkLayerExerciseFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    rootView = inflater.inflate(R.layout.fragment_layer, container, false);
    //TextView para mostrar la pregunta
    pregunta = (TextView) rootView.findViewById(R.id.textlayer);
    //TextView para los puntos en el modo jugar
    layerPoints = (TextView) rootView.findViewById(R.id.points_layer);

    //Radiogrup//from w  w  w  .  j a  v a2s. c  o m
    opciones = (RadioGroup) rootView.findViewById(R.id.layer_group);
    rb_layer = (RadioButton) rootView.findViewById(R.id.link_layer);
    rb_network = (RadioButton) rootView.findViewById(R.id.internet_layer);
    rb_transport = (RadioButton) rootView.findViewById(R.id.transport_layer);
    rb_application = (RadioButton) rootView.findViewById(R.id.application_layer);

    opciones.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup rGroup, int checkedId) {
            // TODO Auto-generated method stub
            switch (checkedId) {
            case R.id.link_layer:
                rb_pressed = "Capa de enlace";
                break;
            case R.id.internet_layer:
                rb_pressed = "Capa de internet";
                break;
            case R.id.transport_layer:
                rb_pressed = "Capa de transporte";
                break;
            case R.id.application_layer:
                rb_pressed = "Capa de aplicacin";
                break;
            }

            RadioButton checkedRadioButton = (RadioButton) opciones
                    .findViewById(opciones.getCheckedRadioButtonId());
            boolean checked = checkedRadioButton.isChecked();
        }
    });

    //Buttons
    comprobar = (Button) rootView.findViewById(R.id.button_layer);
    solucion = (Button) rootView.findViewById(R.id.button_solutionlayer);

    comprobar.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (v.getId() == R.id.button_layer) {
                CompruebaRespuesta();
            }
        }
    });

    solucion.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (v.getId() == R.id.button_solutionlayer) {
                Solucion();
            }
        }
    });

    //Arrays
    preguntas = getResources().getStringArray(R.array.layer_exercise_questions);
    respuestas = getResources().getStringArray(R.array.layer_exercise_answers);
    RANDOM();
    pregunta.setText(preguntas[indice]);

    return rootView;
}

From source file:com.blueverdi.rosietheriveter.MoreFragment.java

public boolean getMapView() {
    RadioButton rb = (RadioButton) view.findViewById(R.id.radioMapView);
    return rb.isChecked();
}

From source file:com.blueverdi.rosietheriveter.MoreFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    boolean checked = false;
    try {/*from w  w  w.  j a va  2 s .  com*/
        RadioButton rb = (RadioButton) view.findViewById(R.id.radioMapView);
        checked = rb.isChecked();
    } catch (Exception e) {
        MyLog.d(TAG, "onSaveInstanceState did not find radio button");
    }
    outState.putBoolean(MAP_VIEW, checked);
}

From source file:com.duy.pascal.ui.file.FileExplorerAction.java

public void showDialogCreateFile(@Nullable final FileActionListener callback) {
    if (mDialog != null && mDialog.isShowing()) {
        mDialog.dismiss();/*from w w w .  ja v a  2s . c  o  m*/
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setView(R.layout.dialog_new_file);

    mDialog = builder.create();
    mDialog.show();

    final EditText editText = mDialog.findViewById(R.id.edit_input);
    View btnOK = mDialog.findViewById(R.id.btn_ok);
    View btnCancel = mDialog.findViewById(R.id.btn_cancel);

    btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mDialog.cancel();
        }
    });
    btnOK.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //get string path of in edit text
            String fileName = editText.getText().toString().trim();
            if (!FileManager.acceptPasFile(fileName)) {
                editText.setError(mContext.getString(R.string.invalid_file_name));
                return;
            }

            RadioButton isProgram = mDialog.findViewById(R.id.rad_program);
            RadioButton isUnit = mDialog.findViewById(R.id.rad_unit);
            RadioButton isInput = mDialog.findViewById(R.id.rad_inp);

            String template = "";
            if (isInput.isChecked()) {
                fileName += ".inp";
            } else if (isUnit.isChecked()) {
                template = CodeTemplate.createUnitTemplate(fileName);
                fileName += ".pas";
            } else if (isProgram.isChecked()) {
                template = CodeTemplate.createProgramTemplate(fileName);
                fileName += ".pas";
            }

            File file = new File(mExplorerContext.getCurrentDirectory(), fileName);
            FileManager fileManager = new FileManager(mContext);
            boolean result = fileManager.createNewFile(file.getPath()) != null;
            if (!result) {
                editText.setError(mContext.getString(R.string.can_not_create_file));
                return;
            } else {
                fileManager.saveFile(file, template);
            }
            if (callback != null) {
                callback.onFileSelected(new File(file.getPath()));
            }
            mView.refresh();
            destroyActionMode();
            mDialog.cancel();
        }
    });
}

From source file:com.boostcamp.hyeon.wallpaper.setting.view.SettingFragment.java

@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    RadioButton radioButton = (RadioButton) group.findViewById(checkedId);
    if (radioButton == null)
        return;//w  w  w. j  a  va 2s  .c o m
    if (group.equals(mChangeRepeatCycleRadioGroup) && radioButton.isChecked()) {
        String value = radioButton.getText().toString();
        int minute = value.indexOf(getString(R.string.label_minute));
        int hour = value.indexOf(getString(R.string.label_hour));

        if (minute != -1 && hour == -1) {
            mChangeCycle = Integer.valueOf(value.substring(0, minute));
            mChangeCycle *= Define.MINUTE_CONVERT_TO_MILLIS;
        } else if (minute == -1 && hour != -1) {
            mChangeCycle = Integer.valueOf(value.substring(0, hour));
            mChangeCycle *= Define.HOUR_CONVERT_TO_MILLIS;
        } else {
            mChangeCycle = Define.CHANGE_CYCLE_SCREEN_OFF;
        }
        Log.d(TAG, "change cycle: " + mChangeCycle);
    }
}

From source file:com.pepperonas.truthordare.fragments.FragmentTwoPlayer.java

@Override
public boolean onMenuItemClick(MenuItem item) {

    Player tmpPlayer;// w w  w .  jav  a 2s. c o  m

    for (int i = 0; i < mLinearFrame.getChildCount(); i++) {

        if (mLinearFrame.getChildAt(i) instanceof Button)
            continue;

        LinearLayout playerLayout = (LinearLayout) mLinearFrame.getChildAt(i);

        EditText etName = (EditText) playerLayout.findViewById(R.id.et_name);
        EditText etJokers = (EditText) playerLayout.findViewById(R.id.et_jokers);
        RadioButton radioFemale = (RadioButton) playerLayout.findViewById(R.id.rb_female);

        if (ensureInput(etName, etJokers))
            return false;

        mMain.getPlayers()
                .add(tmpPlayer = new Player(mMain.getPlayers().size(), etName.getText().toString(),
                        Integer.parseInt(etJokers.getText().toString()),
                        radioFemale.isChecked() ? Gender.FEMALE : Gender.MALE));

        mMain.getDatabase().addPlayer(tmpPlayer.getId(), tmpPlayer.getName(), tmpPlayer.getGender(), true);
    }

    showPlayerLog();

    mMain.makeFragmentTransaction(FragmentSelectAction.newInstance(0));

    return true;
}

From source file:th.in.ffc.person.PersonDetailEditFragment.java

@Override
public boolean onSave(EditTransaction et) {
    String id = citizenId.getText().toString();
    if (!TextUtils.isEmpty(id)) {
        if (!ThaiCitizenID.Validate(id) && !isCurrentId) {
            et.showErrorMessage(citizenId, "Invalid checksum citizen id");
            return false;
        } else if (!isUseableId) {
            et.showErrorMessage(citizenId, "Duplicate Id");
            return false;
        }/*from  w  w w.  j  av a 2 s .  c o m*/
        et.retrieveData(Person.CITIZEN_ID, citizenId, true, "\\d{13}", "Invalid citizen id Lenght");
    } else {
        if (newPid > 0) {
            String cid = "";
            String pid = "" + newPid;
            int loop = (13 - pid.length());
            for (int i = 1; i <= loop; i++)
                cid += "0";
            cid += newPid;
            et.getContentValues().put(Person.CITIZEN_ID, cid);
        }
    }

    et.retrieveData(Person.FIRST_NAME, fname, false, null, null);
    et.retrieveData(Person.LAST_NAME, lname, false, null, null);
    et.retrieveData(Person.BIRTH, birthday, null, Date.newInstance(DateTime.getCurrentDate()),
            "can't create person of the future");
    et.retrieveData(Person.NATION, nation, false, null, "please select one nation");
    et.retrieveData(Person.ORIGIN, origin, false, null, "please select one origin nation");
    et.retrieveData(Person.OCCUPA, occupa, false, null, "please select one occupa");
    et.retrieveData(Person.INCOME, income, true, 0.00f, Float.MAX_VALUE, "Is that to much income");
    et.retrieveData(Person.TEL, tel, true, "\\d{9,12}", "tel number out of lenght");
    et.retrieveData(Person.ALLERGIC, allergic, true, null, null);

    et.retrieveData(Person.ADDR_NO, hno, false, null, "please insert house number");
    et.retrieveData(Person.ADDR_MU, mu, false, null, null);
    et.retrieveData(Person.ADDR_ROAD, road, true, null, null);
    et.retrieveData(Person.ADDR_SUBDIST, subdistcode, false, null, "please select sub-distict");
    et.retrieveData(Person.ADDR_DIST, distcode, false, null, "please select distict");
    et.retrieveData(Person.ADDR_PROVICE, provcode, false, null, "please select Provice");
    et.retrieveData(Person.POSTCODE, postcode, false, "\\d{5}", "please insert 5 digit");

    ContentValues cv = et.getContentValues();

    RadioButton maleRadio = (RadioButton) sex.findViewById(R.id.male);
    cv.put(Person.SEX, maleRadio.isChecked() ? 1 : 2);
    cv.put(Person.PRENAME, prename.getSelectionId());
    cv.put(Person.BLOOD_GROUP, bloodType.getSelectionId());
    cv.put(Person.BLOOD_RH, bloodRh.getSelectionId());
    cv.put(Person.RELIGION, religion.getSelectionId());
    cv.put(Person.EDUCATION, education.getSelectionId());
    cv.put(Person.HCODE, house.getSelectedItemId());
    cv.put(Person._DATEUPDATE, DateTime.getCurrentDateTime());

    if (newPid > 0) {
        cv.put(Person.PID, newPid);
        cv.put(Person.PCUPERSONCODE, getFFCActivity().getPcuCode());
    }

    return et.canCommit();
}

From source file:com.clevertrail.mobile.findtrail.Activity_FindTrail_ByLocation.java

private int submitSearch() {
    double dSearchLat = 0;
    double dSearchLong = 0;
    double dSearchDistance = 0;

    if (!Utils.isNetworkAvailable(mActivity)) {
        return R.string.error_nointernetconnection;
    }//w w w. jav  a 2 s  .c  om

    // is this searching by proximity
    RadioButton rbProximity = (RadioButton) findViewById(R.id.rbFindTrailByLocationProximity);
    if (rbProximity != null && rbProximity.isChecked()) {
        // search by proximity

        // do we have a location?
        if (currentLocation != null) {
            dSearchLat = currentLocation.getLatitude();
            dSearchLong = currentLocation.getLongitude();
        } else {
            return R.string.error_currentlocationnotfound;
        }
    } else {
        //searching by city
        EditText etCity = (EditText) findViewById(R.id.txtFindTrailByLocationCity);
        if (etCity != null) {
            String sCity = etCity.getText().toString();
            if (sCity.compareTo("") != 0) {
                //get the json info about the location from google maps
                JSONObject json = getLocationInfo(sCity);
                if (json == null) {
                    return R.string.error_couldnotconnecttogooglemaps;
                } else {
                    //get the lat/lng from the geocoding result from google maps
                    Point pt = getLatLong(json);
                    if (pt != null) {
                        dSearchLat = pt.dLat;
                        dSearchLong = pt.dLng;
                    } else {
                        return R.string.error_googlecouldnotfindcity;
                    }
                }

            } else {
                return R.string.error_entercityname;
            }
        }
    }

    //find out how far the search radius will be
    int nProximityPos = m_cbFindTrailByLocationProximity.getSelectedItemPosition();
    switch (nProximityPos) {
    case 0:
        dSearchDistance = 5;
        break;
    case 1:
        dSearchDistance = 10;
        break;
    case 2:
        dSearchDistance = 25;
        break;
    case 3:
        dSearchDistance = 50;
        break;
    case 4:
        dSearchDistance = 100;
        break;
    }

    // search for the given lat/long/dist
    JSONArray trailListJSON = fetchTrailListJSON(dSearchLat, dSearchLong, dSearchDistance);

    //do we have a trails that fit the criteria?
    if (trailListJSON != null && trailListJSON.length() > 0) {
        int len = trailListJSON.length();

        try {
            Object_TrailList.clearTrails();
            for (int i = 0; i < len; ++i) {
                JSONObject trail = trailListJSON.getJSONObject(i);
                Object_TrailList.addTrailWithJSON(trail);
            }
        } catch (JSONException e) {
            return R.string.error_corrupttrailinfo;
        }

        Intent i = new Intent(mActivity, Activity_FindTrail_DisplayMap.class);
        mActivity.startActivity(i);
    } else {
        return R.string.error_notrailsfoundinsearchradius;
    }
    return 0;
}

From source file:com.javielinux.tweettopics2.SearchActivity.java

private void save() {
    String error = "";
    boolean save_tweets = false;

    String name_value = "";

    String searchAnd_value = fragmentAdapter.getSearchGeneralFragment().searchAnd.getText().toString();
    search_entity.setValue("words_and", searchAnd_value);

    if (!searchAnd_value.equals(""))
        if (name_value.length() <= 0)
            name_value = searchAnd_value;

    String searchOr_value = fragmentAdapter.getSearchGeneralFragment().searchOr.getText().toString();
    search_entity.setValue("words_or", searchOr_value);

    if (!searchOr_value.equals(""))
        if (name_value.length() <= 0)
            name_value = searchOr_value;

    String searchNot_value = fragmentAdapter.getSearchGeneralFragment().searchNot.getText().toString();
    search_entity.setValue("words_not", searchNot_value);

    if (!searchNot_value.equals(""))
        if (name_value.length() <= 0)
            name_value = searchNot_value;

    String searchFromUser_value = fragmentAdapter.getSearchGeneralFragment().searchFromUser.getText()
            .toString();//from ww w  . j  av a2s  . c o  m
    search_entity.setValue("from_user", searchFromUser_value);

    if (!searchFromUser_value.equals(""))
        if (name_value.length() <= 0)
            name_value = searchFromUser_value;

    String searchToUser_value = fragmentAdapter.getSearchGeneralFragment().searchToUser.getText().toString();
    search_entity.setValue("to_user", searchToUser_value);

    if (!searchToUser_value.equals(""))
        if (name_value.length() <= 0)
            name_value = searchToUser_value;

    if (searchAnd_value.equals("") && searchOr_value.equals("") && searchNot_value.equals("")
            && searchFromUser_value.equals("") && searchToUser_value.equals("")) {
        error = this.getString(R.string.error_search_text);
    }

    EditText name = fragmentAdapter.getSearchGeneralFragment().name;

    if (name.getText().toString().equals("")) {
        if (name_value.length() > 1)
            name_value = name_value.substring(0, 1).toUpperCase() + name_value.substring(1);

        search_entity.setValue("name", name_value);
    } else {
        search_entity.setValue("name", name.getText().toString());
    }

    long icon_id = fragmentAdapter.getSearchGeneralFragment().iconId;
    String token_file = fragmentAdapter.getSearchGeneralFragment().iconFile;

    search_entity.setValue("icon_id", icon_id);
    search_entity.setValue("icon_token_file", token_file);

    if (icon_id > 1) {
        Entity icon = new Entity("icons", icon_id);
        search_entity.setValue("icon_big", "drawable/" + icon.getValue("icon"));
        search_entity.setValue("icon_small", "drawable/" + icon.getValue("icon_small"));
    } else if (icon_id == 1) {
        search_entity.setValue("icon_big", Utils.getIconGeneric(this, name_value));
        search_entity.setValue("icon_small", Utils.getIconGeneric(this, name_value) + "_small");
    } else {
        search_entity.setValue("icon_big", "file/" + token_file + ".png");
        search_entity.setValue("icon_small", "file/" + token_file + "_small.png");
    }

    if (search_entity.getId() < 0) {
        search_entity.setValue("date_create", Utils.now());
        search_entity.setValue("last_modified", Utils.now());
        search_entity.setValue("use_count", 0);
    }

    Spinner languages = fragmentAdapter.getSearchAdvancedFragment().languages;

    if (languages.getSelectedItemPosition() != AdapterView.INVALID_POSITION) {
        String[] language_values = getResources().getStringArray(R.array.languages_values);
        search_entity.setValue("lang", language_values[languages.getSelectedItemPosition()]);
    }

    Spinner attitude = fragmentAdapter.getSearchAdvancedFragment().attitude;

    if (attitude.getSelectedItemPosition() != AdapterView.INVALID_POSITION)
        search_entity.setValue("attitude", attitude.getSelectedItemPosition());

    Spinner filter = fragmentAdapter.getSearchAdvancedFragment().filter;

    if (filter.getSelectedItemPosition() != AdapterView.INVALID_POSITION)
        search_entity.setValue("filter", filter.getSelectedItemPosition());

    CheckBox noRetweet = fragmentAdapter.getSearchAdvancedFragment().noRetweet;

    if (noRetweet.isChecked())
        search_entity.setValue("no_retweet", 1);
    else
        search_entity.setValue("no_retweet", 0);

    EditText searchSource = fragmentAdapter.getSearchAdvancedFragment().source;
    search_entity.setValue("source", searchSource.getText().toString());

    CheckBox notifications = fragmentAdapter.getSearchAdvancedFragment().notifications;

    // Borrar todos los tweets en el caso que deje de notificarse la bsqueda
    if (!notifications.isChecked() && search_entity.getInt("notifications") == 1) {
        DataFramework.getInstance().getDB()
                .execSQL("DELETE FROM tweets WHERE search_id = " + search_entity.getId() + " AND favorite = 0");
        search_entity.setValue("last_tweet_id", "0");
        search_entity.setValue("last_tweet_id_notifications", "0");
        search_entity.setValue("new_tweets_count", "0");
    }

    // Guarda los primeros tweets en el caso de empezar a notificar
    if (notifications.isChecked() && search_entity.getInt("notifications") == 0) {
        save_tweets = true;
    }

    if (notifications.isChecked())
        search_entity.setValue("notifications", 1);
    else
        search_entity.setValue("notifications", 0);

    CheckBox notificationsBar = fragmentAdapter.getSearchAdvancedFragment().notificationsBar;

    if (notificationsBar.isChecked())
        search_entity.setValue("notifications_bar", 1);
    else
        search_entity.setValue("notifications_bar", 0);

    if (fragmentAdapter.getSearchGeoFragment() != null) {
        CheckBox useGeolocation = fragmentAdapter.getSearchGeoFragment().useGeo;

        if (useGeolocation.isChecked()) {
            search_entity.setValue("use_geo", 1);

            RadioButton typeGeolocationGPS = fragmentAdapter.getSearchGeoFragment().typeGeoGPS;

            if (typeGeolocationGPS.isChecked())
                search_entity.setValue("type_geo", 1);
            else
                search_entity.setValue("type_geo", 0);

            EditText latitude = fragmentAdapter.getSearchGeoFragment().latitude;
            EditText longitude = fragmentAdapter.getSearchGeoFragment().longitude;

            try {
                float latitude_value = Float.parseFloat(latitude.getText().toString());
                float longitude_value = Float.parseFloat(longitude.getText().toString());

                search_entity.setValue("latitude", latitude_value);
                search_entity.setValue("longitude", longitude_value);
            } catch (Exception exception) {
                error = this.getString(R.string.error_search_coord);
            }

            if (error.length() == 0) {
                SeekBar distance = fragmentAdapter.getSearchGeoFragment().distance;

                if (distance.getProgress() > 0) {
                    search_entity.setValue("distance", distance.getProgress());

                    RadioButton typeDistanceKm = fragmentAdapter.getSearchGeoFragment().typeDistanceKM;

                    if (typeDistanceKm.isChecked()) {
                        search_entity.setValue("type_distance", 1);
                    } else {
                        search_entity.setValue("type_distance", 0);
                    }
                } else {
                    error = this.getString(R.string.error_search_distance);
                }
            }
        } else {
            search_entity.setValue("use_geo", 0);
        }
    } else {
        search_entity.setValue("use_geo", 0);
    }

    if (error.length() == 0) {
        if (save_tweets)
            saveTweets();
        else
            exitActivity();
    } else {
        Utils.showMessage(this, error);
    }
}

From source file:com.pepperonas.truthordare.fragments.FragmentMultiplayer.java

@Override
public boolean onMenuItemClick(MenuItem item) {
    Log.d(TAG, "onMenuItemClick  " + "");

    if (mLlm.getChildCount() < 2) {
        ToastUtils.toastShort(R.string.at_least_two_players);
        return false;
    }//from w w  w.  j a  va  2s .  c  o  m

    mMain.getPlayers().clear();

    Player tmpPlayer;

    for (int i = 0; i < mLlm.getChildCount(); i++) {

        if (mLlm.getChildAt(i) instanceof Button)
            continue;

        LinearLayout playerLayout = (LinearLayout) mLlm.getChildAt(i);

        EditText etName = (EditText) playerLayout.findViewById(R.id.et_name);
        EditText etJokers = (EditText) playerLayout.findViewById(R.id.et_jokers);
        RadioButton radioFemale = (RadioButton) playerLayout.findViewById(R.id.rb_female);

        if (ensureInput(etName, etJokers))
            return false;

        mMain.getPlayers()
                .add(tmpPlayer = new Player(mMain.getPlayers().size(), etName.getText().toString(),
                        Integer.parseInt(etJokers.getText().toString()),
                        radioFemale.isChecked() ? Gender.FEMALE : Gender.MALE));

        mMain.getDatabase().addPlayer(tmpPlayer.getId(), tmpPlayer.getName(), tmpPlayer.getGender(), true);
    }

    showPlayerLog();

    mMain.makeFragmentTransaction(FragmentSelectAction.newInstance(0));
    return true;
}