Search in sources :

Example 61 with RadioGroup

use of android.widget.RadioGroup in project android_frameworks_base by ResurrectionRemix.

the class NotificationBuilderTest method getRadioTag.

private String getRadioTag(int id) {
    final RadioGroup g = (RadioGroup) findViewById(id);
    final View v = findViewById(g.getCheckedRadioButtonId());
    return (String) v.getTag();
}
Also used : RadioGroup(android.widget.RadioGroup) View(android.view.View)

Example 62 with RadioGroup

use of android.widget.RadioGroup in project android_frameworks_base by crdroidandroid.

the class HugeBackupActivity method populateUI.

/**
     * Configure the UI based on our persistent data, creating the
     * data file and establishing defaults if necessary.
     */
void populateUI() {
    RandomAccessFile file;
    // Default values in case there's no data file yet
    int whichFilling = R.id.pastrami;
    boolean addMayo = false;
    boolean addTomato = false;
    /** Hold the data-access lock around access to the file */
    synchronized (HugeBackupActivity.sDataLock) {
        boolean exists = mDataFile.exists();
        try {
            file = new RandomAccessFile(mDataFile, "rw");
            if (exists) {
                Log.v(TAG, "datafile exists");
                whichFilling = file.readInt();
                addMayo = file.readBoolean();
                addTomato = file.readBoolean();
                Log.v(TAG, "  mayo=" + addMayo + " tomato=" + addTomato + " filling=" + whichFilling);
            } else {
                // The default values were configured above: write them
                // to the newly-created file.
                Log.v(TAG, "creating default datafile");
                writeDataToFileLocked(file, addMayo, addTomato, whichFilling);
                // We also need to perform an initial backup; ask for one
                mBackupManager.dataChanged();
            }
        } catch (IOException ioe) {
        }
    }
    /** Now that we've processed the file, build the UI outside the lock */
    mFillingGroup.check(whichFilling);
    mAddMayoCheckbox.setChecked(addMayo);
    mAddTomatoCheckbox.setChecked(addTomato);
    /**
         * We also want to record the new state when the user makes changes,
         * so install simple observers that do this
         */
    mFillingGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        public void onCheckedChanged(RadioGroup group, int checkedId) {
            // As with the checkbox listeners, rewrite the
            // entire state file
            Log.v(TAG, "New radio item selected: " + checkedId);
            recordNewUIState();
        }
    });
    CompoundButton.OnCheckedChangeListener checkListener = new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // Whichever one is altered, we rewrite the entire UI state
            Log.v(TAG, "Checkbox toggled: " + buttonView);
            recordNewUIState();
        }
    };
    mAddMayoCheckbox.setOnCheckedChangeListener(checkListener);
    mAddTomatoCheckbox.setOnCheckedChangeListener(checkListener);
}
Also used : RandomAccessFile(java.io.RandomAccessFile) RadioGroup(android.widget.RadioGroup) IOException(java.io.IOException) CompoundButton(android.widget.CompoundButton)

Aggregations

RadioGroup (android.widget.RadioGroup)62 View (android.view.View)26 TextView (android.widget.TextView)19 RadioButton (android.widget.RadioButton)13 OnCheckedChangeListener (android.widget.RadioGroup.OnCheckedChangeListener)13 Button (android.widget.Button)9 CompoundButton (android.widget.CompoundButton)8 Validator (com.mobsandgeeks.saripaar.Validator)8 CheckBox (android.widget.CheckBox)5 IOException (java.io.IOException)5 RandomAccessFile (java.io.RandomAccessFile)5 Test (org.junit.Test)5 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)4 ImageView (android.widget.ImageView)4 ScrollView (android.widget.ScrollView)4 Paint (android.graphics.Paint)3 AlertDialog (android.support.v7.app.AlertDialog)3 LinearLayout (android.widget.LinearLayout)3 SeekBar (android.widget.SeekBar)3