Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database Android RadioButton是否返回常量?_Database_Android_Radio Button_Constants - Fatal编程技术网

Database Android RadioButton是否返回常量?

Database Android RadioButton是否返回常量?,database,android,radio-button,constants,Database,Android,Radio Button,Constants,我正在尝试执行一个评级系统,在这个系统中,通过选择返回一个常量,这样我就可以在数据库中插入一个值。我的意图是有三个选择,“伟大”、“平庸”和“糟糕”。我很想成为“3”的常数,平庸的想成为“2”的常数,糟糕的想成为“1”的常数。如果可能,我只想插入数值,有没有简单的方法 AnthonyRadioGroup具有方法getCheckedRadioButtonId(),该方法返回所选RadioButtonid的资源id 您可以设置如下开关盒: private static final int CHOIC

我正在尝试执行一个评级系统,在这个系统中,通过选择返回一个常量,这样我就可以在数据库中插入一个值。我的意图是有三个选择,“伟大”、“平庸”和“糟糕”。我很想成为“3”的常数,平庸的想成为“2”的常数,糟糕的想成为“1”的常数。如果可能,我只想插入数值,有没有简单的方法


Anthony

RadioGroup具有方法
getCheckedRadioButtonId()
,该方法返回所选
RadioButtonid
的资源id

您可以设置如下开关盒:

private static final int CHOICE_GREAT = 3;
private static final int CHOICE_MEDIOCRE = 2;
private static final int CHOICE_BAD = 1;

int selected = getRating();

private int getRating() {
    switch (ratingGroup.getCheckedRadioButtonId()) {
       case R.id.RadioButtonGreat:
          return CHOICE_GREAT;
       case R.id.RadioButtonMediocre:
          return CHOICE_MEDIOCRE;
       case R.id.RadioButtonBad:
          return CHOICE_BAD;
    }
}

RadioGroup
具有方法
getCheckedRadioButtonId()
,该方法返回所选
单选按钮的资源id

您可以设置如下开关盒:

private static final int CHOICE_GREAT = 3;
private static final int CHOICE_MEDIOCRE = 2;
private static final int CHOICE_BAD = 1;

int selected = getRating();

private int getRating() {
    switch (ratingGroup.getCheckedRadioButtonId()) {
       case R.id.RadioButtonGreat:
          return CHOICE_GREAT;
       case R.id.RadioButtonMediocre:
          return CHOICE_MEDIOCRE;
       case R.id.RadioButtonBad:
          return CHOICE_BAD;
    }
}