问题
I am trying to create a mobile application about healthcare. I have to create a survey like application to screen the patients. Right now i have completed a part of the survey using radio button, the other part also look something like this(see picture below) but i want the radio button change to numeric textbox.
My application look something like this:
Right now I want to convert the radio button to a numeric textbox.
The question is: how can i make minimum code changes and replace all the radio button to numeric textbox?
Here is my code for the radio buttons:
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
来源:https://stackoverflow.com/questions/48184075/corona-coverting-radio-button-to-numeric-textbox-lua