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();
}
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);
}
Aggregations