Search in sources :

Example 41 with RadioButton

use of android.widget.RadioButton in project iosched by google.

the class VideoLibraryFilteredFragment method updateRadioGroup.

/**
     * Generates RadioButton for each item of the {@code values} list and adds them to the {@code
     * radioGroup}. The item equals to {@code selectedValue} will be checked initially. Items with
     * special Labels can be added using {@code specialValues}. They will be added on top and in
     * uppercase characters.
     */
private <T extends Comparable> void updateRadioGroup(final RadioGroup radioGroup, List<T> values, T selectedValue, Map<T, String> specialValues) {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (radioGroup == null) {
        return;
    }
    // Add special Values to the list
    List<T> specialItemsList = new ArrayList<>(specialValues.keySet());
    Collections.sort(specialItemsList);
    for (T keys : specialItemsList) {
        values.add(0, keys);
    }
    radioGroup.removeAllViews();
    radioGroup.clearCheck();
    int idCounter = 0;
    for (final T value : values) {
        View buttonLayout = inflater.inflate(R.layout.video_library_filter_radio_button, radioGroup, false);
        final RadioButton button = (RadioButton) buttonLayout.findViewById(R.id.button);
        radioGroup.addView(buttonLayout);
        // Set the Label of the Radio Button.
        TextView text = (TextView) buttonLayout.findViewById(R.id.text);
        text.setText(specialValues.get(value) == null ? value.toString() : specialValues.get(value));
        // We have to give different IDs to all the RadioButtons inside the RadioGroup so that
        // only one can be checked at a time.
        button.setId(idCounter);
        idCounter++;
        // Trigger a RadioButton click when clicking the Text.
        text.setOnClickListener(new View.OnClickListener() {

            @Override
            @TargetApi(15)
            public void onClick(View v) {
                button.callOnClick();
            }
        });
        // When Clicking the RadioButton filter when re-filter the videos.
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                radioGroup.check(button.getId());
                onVideoFilterChanged(value);
            }
        });
        if (selectedValue.equals(value)) {
            radioGroup.check(button.getId());
        }
    }
}
Also used : LayoutInflater(android.view.LayoutInflater) ArrayList(java.util.ArrayList) TextView(android.widget.TextView) RadioButton(android.widget.RadioButton) View(android.view.View) UpdatableView(com.google.samples.apps.iosched.archframework.UpdatableView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) TargetApi(android.annotation.TargetApi)

Example 42 with RadioButton

use of android.widget.RadioButton in project ImagePicker by jeasonlzy.

the class ImagePickerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image_picker);
    imagePicker = ImagePicker.getInstance();
    imagePicker.setImageLoader(new GlideImageLoader());
    rb_uil = (RadioButton) findViewById(R.id.rb_uil);
    rb_glide = (RadioButton) findViewById(R.id.rb_glide);
    rb_picasso = (RadioButton) findViewById(R.id.rb_picasso);
    rb_fresco = (RadioButton) findViewById(R.id.rb_fresco);
    rb_xutils3 = (RadioButton) findViewById(R.id.rb_xutils3);
    rb_xutils = (RadioButton) findViewById(R.id.rb_xutils);
    rb_single_select = (RadioButton) findViewById(R.id.rb_single_select);
    rb_muti_select = (RadioButton) findViewById(R.id.rb_muti_select);
    rb_crop_square = (RadioButton) findViewById(R.id.rb_crop_square);
    rb_crop_circle = (RadioButton) findViewById(R.id.rb_crop_circle);
    rb_glide.setChecked(true);
    rb_muti_select.setChecked(true);
    rb_crop_square.setChecked(true);
    et_crop_width = (EditText) findViewById(R.id.et_crop_width);
    et_crop_width.setText("280");
    et_crop_height = (EditText) findViewById(R.id.et_crop_height);
    et_crop_height.setText("280");
    et_crop_radius = (EditText) findViewById(R.id.et_crop_radius);
    et_crop_radius.setText("140");
    et_outputx = (EditText) findViewById(R.id.et_outputx);
    et_outputx.setText("800");
    et_outputy = (EditText) findViewById(R.id.et_outputy);
    et_outputy.setText("800");
    tv_select_limit = (TextView) findViewById(R.id.tv_select_limit);
    SeekBar sb_select_limit = (SeekBar) findViewById(R.id.sb_select_limit);
    sb_select_limit.setMax(15);
    sb_select_limit.setOnSeekBarChangeListener(this);
    sb_select_limit.setProgress(9);
    CheckBox cb_show_camera = (CheckBox) findViewById(R.id.cb_show_camera);
    cb_show_camera.setOnCheckedChangeListener(this);
    cb_show_camera.setChecked(true);
    CheckBox cb_crop = (CheckBox) findViewById(R.id.cb_crop);
    cb_crop.setOnCheckedChangeListener(this);
    cb_crop.setChecked(true);
    CheckBox cb_isSaveRectangle = (CheckBox) findViewById(R.id.cb_isSaveRectangle);
    cb_isSaveRectangle.setOnCheckedChangeListener(this);
    cb_isSaveRectangle.setChecked(true);
    Button btn_open_gallery = (Button) findViewById(R.id.btn_open_gallery);
    btn_open_gallery.setOnClickListener(this);
    Button btn_wxDemo = (Button) findViewById(R.id.btn_wxDemo);
    btn_wxDemo.setOnClickListener(this);
    gridView = (GridView) findViewById(R.id.gridview);
}
Also used : SeekBar(android.widget.SeekBar) RadioButton(android.widget.RadioButton) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) CheckBox(android.widget.CheckBox) GlideImageLoader(com.lzy.imagepickerdemo.imageloader.GlideImageLoader)

Example 43 with RadioButton

use of android.widget.RadioButton in project Android-Developers-Samples by johnjohndoe.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_layout);
    /*
         * Initialize UI
         */
    //Set up main image view
    mBitmapIn = loadBitmap(R.drawable.data);
    mBitmapsOut = new Bitmap[NUM_BITMAPS];
    for (int i = 0; i < NUM_BITMAPS; ++i) {
        mBitmapsOut[i] = Bitmap.createBitmap(mBitmapIn.getWidth(), mBitmapIn.getHeight(), mBitmapIn.getConfig());
    }
    mImageView = (ImageView) findViewById(R.id.imageView);
    mImageView.setImageBitmap(mBitmapsOut[mCurrentBitmap]);
    mCurrentBitmap += (mCurrentBitmap + 1) % NUM_BITMAPS;
    //Set up seekbar
    final SeekBar seekbar = (SeekBar) findViewById(R.id.seekBar1);
    seekbar.setProgress(50);
    seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            updateImage(progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    //Setup effect selector
    RadioButton radio0 = (RadioButton) findViewById(R.id.radio0);
    radio0.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mFilterMode = MODE_BLUR;
                updateImage(seekbar.getProgress());
            }
        }
    });
    RadioButton radio1 = (RadioButton) findViewById(R.id.radio1);
    radio1.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mFilterMode = MODE_CONVOLVE;
                updateImage(seekbar.getProgress());
            }
        }
    });
    RadioButton radio2 = (RadioButton) findViewById(R.id.radio2);
    radio2.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mFilterMode = MODE_COLORMATRIX;
                updateImage(seekbar.getProgress());
            }
        }
    });
    /*
         * Create renderScript
         */
    createScript();
    /*
         * Create thumbnails
         */
    createThumbnail();
    /*
         * Invoke renderScript kernel and update imageView
         */
    mFilterMode = MODE_BLUR;
    updateImage(50);
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SeekBar(android.widget.SeekBar) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) RadioButton(android.widget.RadioButton) CompoundButton(android.widget.CompoundButton)

Example 44 with RadioButton

use of android.widget.RadioButton in project Pokemap by omkarmoghe.

the class ThemeActivity method onRadioButtonClicked.

public void onRadioButtonClicked(View v) {
    SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.pref_file_key), Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPref.edit();
    boolean checked = ((RadioButton) v).isChecked();
    switch(v.getId()) {
        case R.id.radioButton1:
            if (checked) {
                editor.putInt(PREF_ID, R.style.AppThemeSquirtle);
                editor.putInt(PREF_ID_NO_ACTION_BAR, R.style.AppThemeSquirtle_NoActionBar);
                editor.apply();
            }
            break;
        case R.id.radioButton2:
            if (checked) {
                editor.putInt(PREF_ID, R.style.AppThemeCharmander);
                editor.putInt(PREF_ID_NO_ACTION_BAR, R.style.AppThemeCharmander_NoActionBar);
                editor.apply();
            }
            break;
        case R.id.radioButton3:
            if (checked) {
                editor.putInt(PREF_ID, R.style.AppThemeBulbasaur);
                editor.putInt(PREF_ID_NO_ACTION_BAR, R.style.AppThemeBulbasaur_NoActionBar);
                editor.apply();
            }
            break;
        case R.id.radioButton4:
            if (checked) {
                editor.putInt(PREF_ID, R.style.AppThemePikachu);
                editor.putInt(PREF_ID_NO_ACTION_BAR, R.style.AppThemePikachu_NoActionBar);
                editor.apply();
            }
            break;
        case R.id.radioButton5:
            if (checked) {
                editor.putInt(PREF_ID, R.style.AppTheme);
                editor.putInt(PREF_ID_NO_ACTION_BAR, R.style.AppTheme_NoActionBar);
                editor.apply();
            }
            break;
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) RadioButton(android.widget.RadioButton)

Example 45 with RadioButton

use of android.widget.RadioButton in project Pokemap by omkarmoghe.

the class ThemeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PREF_ID = getString(R.string.pref_theme);
    PREF_ID_NO_ACTION_BAR = getString(R.string.pref_theme_no_action_bar);
    sharedPref = this.getSharedPreferences(getString(R.string.pref_file_key), Context.MODE_PRIVATE);
    themeId = sharedPref.getInt(getString(R.string.pref_theme), R.style.AppTheme);
    setTheme(themeId);
    setTitle(getString(R.string.preset_themes_title));
    setContentView(R.layout.activity_theme);
    RadioButton r1 = (RadioButton) findViewById(R.id.radioButton1);
    RadioButton r2 = (RadioButton) findViewById(R.id.radioButton2);
    RadioButton r3 = (RadioButton) findViewById(R.id.radioButton3);
    RadioButton r4 = (RadioButton) findViewById(R.id.radioButton4);
    RadioButton r5 = (RadioButton) findViewById(R.id.radioButton5);
    switch(themeId) {
        case R.style.AppThemeSquirtle:
            r1.setChecked(true);
            break;
        case R.style.AppThemeCharmander:
            r2.setChecked(true);
            break;
        case R.style.AppThemeBulbasaur:
            r3.setChecked(true);
            break;
        case R.style.AppThemePikachu:
            r4.setChecked(true);
            break;
        case R.style.AppTheme:
            r5.setChecked(true);
            break;
        default:
            break;
    }
}
Also used : RadioButton(android.widget.RadioButton)

Aggregations

RadioButton (android.widget.RadioButton)82 View (android.view.View)43 TextView (android.widget.TextView)30 Button (android.widget.Button)16 CheckBox (android.widget.CheckBox)15 RadioGroup (android.widget.RadioGroup)14 Intent (android.content.Intent)11 EditText (android.widget.EditText)11 Bundle (android.os.Bundle)10 ViewGroup (android.view.ViewGroup)8 CompoundButton (android.widget.CompoundButton)8 ImageView (android.widget.ImageView)7 ScrollView (android.widget.ScrollView)7 RemoteException (android.os.RemoteException)6 AdapterView (android.widget.AdapterView)6 Test (org.junit.Test)6 LayoutInflater (android.view.LayoutInflater)5 SeekBar (android.widget.SeekBar)5 OnClickListener (android.view.View.OnClickListener)4 OnCheckedChangeListener (android.widget.RadioGroup.OnCheckedChangeListener)4