电晕将单选按钮转换为数字文本框(lua)

时间:2018-01-10 09:25:12

标签: lua corona

我正在尝试创建一个关于医疗保健的移动应用程序。我必须创建一个类似于应用程序的调查来筛选患者。现在我已经使用单选按钮完成了部分调查,另一部分也看起来像这样(见下图)但我希望单选按钮更改为数字文本框。我的应用程序看起来像这样:

radio button

现在我想将单选按钮转换为数字文本框 问题是:如何进行最少的代码更改并将所有单选按钮替换为数字文本框?
这是我的单选按钮代码:

local radioGroup = display.newGroup()

    if(ebasRating_Arr[i] == 0) then
        radioButton_0 = widget.newSwitch {
            left = 565,
            style = "radio",
            initialSwitchState = true,
            id = tostring(i),
            width = 60,
            height = 60,
            onPress = setEBASRating0
        }
        radioGroup:insert( radioButton_0 )

        radioButton_1 = widget.newSwitch {
            style = "radio",
            id = tostring(i),
            initialSwitchState = false,
            width = 60,
            height = 60,
            onPress = setEBASRating1
        }
        radioGroup:insert( radioButton_1 )

    elseif (ebasRating_Arr[i] == 1) then
        radioButton_0 = widget.newSwitch {
            left = 565,
            style = "radio",
            initialSwitchState = false,
            id = tostring(i),
            width = 60,
            height = 60,
            onPress = setEBASRating0
        }
        radioGroup:insert( radioButton_0 )

        radioButton_1 = widget.newSwitch {
            style = "radio",
            id = tostring(i),
            initialSwitchState = true,
            width = 60,
            height = 60,
            onPress = setEBASRating1
        }
        radioGroup:insert( radioButton_1 )
    else
        radioButton_0 = widget.newSwitch {
            left = 565,
            style = "radio",
            initialSwitchState = false,
            id = tostring(i),
            width = 60,
            height = 60,
            onPress = setEBASRating0
        }
        radioGroup:insert( radioButton_0 )

        radioButton_1 = widget.newSwitch {
            style = "radio",
            id = tostring(i),
            initialSwitchState = false,
            width = 60,
            height = 60,
            onPress = setEBASRating1
        }
        radioGroup:insert( radioButton_1 )
    end

    radioButton_0.y = 150 + (i * 450)
    radioButton_1.x = 18 + radioButton_0.x+radioButton_0.width
    radioButton_1.y =  150 + (i * 450)
    scrollView:insert( radioGroup )

end

0 个答案:

没有答案