Search in sources :

Example 61 with RadioButton

use of android.widget.RadioButton in project iNaturalistAndroid by inaturalist.

the class NetworkSettings method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHelper = new ActivityHelper(this);
    final Intent intent = getIntent();
    setContentView(R.layout.inat_network_settings);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setTitle(R.string.inat_network);
    mNetworks = (RadioGroup) findViewById(R.id.networks);
    mMoreInfo = (ViewGroup) findViewById(R.id.more_info);
    if (mApp == null) {
        mApp = (INaturalistApp) getApplicationContext();
    }
    mMoreInfo.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(getString(R.string.inat_network_info_url)));
            startActivity(i);
        }
    });
    String[] networks = mApp.getINatNetworks();
    String network = mApp.getInaturalistNetworkMember();
    int selectedNetwork = 0;
    mNetworkRadioButtons = new ArrayList<RadioButton>();
    for (int i = 0; i < networks.length; i++) {
        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final ViewGroup customNetworkOption = (ViewGroup) inflater.inflate(R.layout.network_option, null, false);
        TextView networkName = (TextView) customNetworkOption.findViewById(R.id.title);
        TextView networkLocation = (TextView) customNetworkOption.findViewById(R.id.sub_title);
        final AppCompatRadioButton radioButton = (AppCompatRadioButton) customNetworkOption.findViewById(R.id.radio_button);
        networkName.setText(mApp.getStringResourceByName("network_" + networks[i]));
        networkLocation.setText(mApp.getStringResourceByName("inat_country_name_" + networks[i]));
        radioButton.setId(i);
        // Set radio button color
        ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_checked }, new int[] { android.R.attr.state_checked } }, new int[] { Color.DKGRAY, getResources().getColor(R.color.inatapptheme_color) });
        radioButton.setSupportButtonTintList(colorStateList);
        final int index = i;
        customNetworkOption.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // Uncheck all other radio buttons
                for (int c = 0; c < mNetworkRadioButtons.size(); c++) {
                    if (c == index)
                        continue;
                    RadioButton r = mNetworkRadioButtons.get(c);
                    r.setChecked(false);
                }
                onINatNetworkRadioButtonClicked(index);
            }
        });
        mNetworkRadioButtons.add(radioButton);
        mNetworks.addView(customNetworkOption);
        if (networks[i].equals(network)) {
            selectedNetwork = i;
        }
    }
    mFormerSelectedNetworkRadioButton = selectedNetwork;
    mNetworkRadioButtons.get(selectedNetwork).setChecked(true);
}
Also used : AppCompatRadioButton(android.support.v7.widget.AppCompatRadioButton) ViewGroup(android.view.ViewGroup) ColorStateList(android.content.res.ColorStateList) Intent(android.content.Intent) RadioButton(android.widget.RadioButton) AppCompatRadioButton(android.support.v7.widget.AppCompatRadioButton) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView)

Example 62 with RadioButton

use of android.widget.RadioButton in project BloodHub by kazijehangir.

the class EmergencyRequestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_emergency_request);
    // INITIALIZE FIREBASE DB
    db = FirebaseDatabase.getInstance().getReference().child("bloodrequests");
    setTitle("Emergency Request");
    name = (AutoCompleteTextView) findViewById(R.id.name);
    bloodgroup = (Spinner) findViewById(R.id.spin);
    quantity = (Spinner) findViewById(R.id.spin1);
    number = (EditText) findViewById(R.id.contact_num);
    location = (AutoCompleteTextView) findViewById(R.id.loc);
    diagnosis = (Spinner) findViewById(R.id.diagnosis);
    transport_group = (RadioGroup) findViewById(R.id.transport);
    String[] hospitals = getResources().getStringArray(R.array.organizations_array);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, hospitals);
    location.setAdapter(adapter);
    Button submit = (Button) findViewById(R.id.submit_button);
    submit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            pname = name.getText().toString();
            bgroup = bloodgroup.getSelectedItem().toString();
            quan = quantity.getSelectedItem().toString();
            diag = diagnosis.getSelectedItem().toString();
            num = number.getText().toString();
            loc = location.getText().toString();
            transport_btn = (RadioButton) findViewById(transport_group.getCheckedRadioButtonId());
            String transport_text = (String) transport_btn.getText();
            if (transport_text.equals("Available")) {
                transport = true;
            } else if (transport_text.equals("Not Available")) {
                transport = false;
            }
            String address = loc + ", Pakistan";
            new GetCoordinates().execute(address.replace(" ", "+"));
        }
    });
}
Also used : RadioButton(android.widget.RadioButton) Button(android.widget.Button) RadioButton(android.widget.RadioButton) View(android.view.View) AutoCompleteTextView(android.widget.AutoCompleteTextView) ArrayAdapter(android.widget.ArrayAdapter)

Example 63 with RadioButton

use of android.widget.RadioButton in project DMGameApp by xiaohaibin.

the class MainActivity method initView.

// 初始化控件
private void initView() {
    mainViewpager = (ViewPager) findViewById(R.id.main_viewpager);
    rgp = (RadioGroup) findViewById(R.id.main_rgp);
    // 设置默认第一个为选中状态
    RadioButton rb = (RadioButton) rgp.getChildAt(0);
    rb.setChecked(true);
}
Also used : RadioButton(android.widget.RadioButton)

Example 64 with RadioButton

use of android.widget.RadioButton in project Osmand by osmandapp.

the class DirectionIndicationDialogFragment method updateMarkerModeRow.

private void updateMarkerModeRow(int rowId, int radioButtonId, boolean checked, boolean active) {
    boolean night = !getSettings().isLightContent();
    RadioButton rb = (RadioButton) mainView.findViewById(radioButtonId);
    int colorId = active ? night ? R.color.osmand_orange : R.color.dashboard_blue : night ? R.color.ctx_menu_info_text_dark : R.color.icon_color;
    rb.setChecked(checked);
    CompoundButtonCompat.setButtonTintList(rb, ColorStateList.valueOf(ContextCompat.getColor(getContext(), colorId)));
    mainView.findViewById(rowId).setEnabled(active);
}
Also used : RadioButton(android.widget.RadioButton) Paint(android.graphics.Paint)

Example 65 with RadioButton

use of android.widget.RadioButton in project alcoholtestapp by dieechtenilente.

the class EditUser method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_modify_user);
    tvName = findViewById(R.id.name);
    tvAge = findViewById(R.id.age);
    tvWeight = findViewById(R.id.weight);
    tvHeight = findViewById(R.id.height);
    male = findViewById(R.id.sex_male);
    RadioButton female = findViewById(R.id.sex_female);
    Button saveUser = findViewById(R.id.saveUser);
    final EditUser eU = this;
    long created = getIntent().getLongExtra("created", 0);
    if (created == 0) {
        finish();
        return;
    }
    try {
        SharedPreferences sharedPref = getSharedPreferences("data", 0);
        JSONArray users = new JSONArray(sharedPref.getString("users", "[]"));
        for (int i = 0; i < users.length(); i++) {
            JSONObject j = new JSONObject(users.get(i).toString());
            if (j.getLong("created") == created) {
                u = new User(new JSONObject(users.get(i).toString()));
                tvName.setText(u.name);
                tvAge.setText(u.age + "");
                tvWeight.setText(u.weight + "");
                tvHeight.setText(u.height + "");
                if (!u.isMale) {
                    female.toggle();
                }
                break;
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    saveUser.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (editUser(u)) {
                startActivity(new Intent(EditUser.this, MainActivity.class));
                finish();
            } else {
                Toast.makeText(eU, eU.getResources().getText(R.string.wronginput), Toast.LENGTH_SHORT).show();
            }
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) Intent(android.content.Intent) RadioButton(android.widget.RadioButton) TextView(android.widget.TextView) View(android.view.View) JSONObject(org.json.JSONObject) RadioButton(android.widget.RadioButton) Button(android.widget.Button)

Aggregations

RadioButton (android.widget.RadioButton)198 View (android.view.View)100 TextView (android.widget.TextView)69 RadioGroup (android.widget.RadioGroup)43 Button (android.widget.Button)38 Intent (android.content.Intent)36 CheckBox (android.widget.CheckBox)28 EditText (android.widget.EditText)26 ImageView (android.widget.ImageView)21 CompoundButton (android.widget.CompoundButton)19 LayoutInflater (android.view.LayoutInflater)18 ViewGroup (android.view.ViewGroup)18 LinearLayout (android.widget.LinearLayout)17 Bundle (android.os.Bundle)16 AdapterView (android.widget.AdapterView)15 DialogInterface (android.content.DialogInterface)14 Context (android.content.Context)10 ScrollView (android.widget.ScrollView)10 ArrayList (java.util.ArrayList)10 SharedPreferences (android.content.SharedPreferences)9