[英]Radiobutton check on user interaction
I am developing a quiz activity based on football formations. 我正在根据足球编队开展测验活动。 I show a list of radio buttons to the user asking him to select the on with the current 'role' in the formation. 我向用户显示了一个单选按钮列表,要求用户选择编队中当前“角色”的打开。 What I am trying to develop here is based on the user click on a radio button to check if the correct radio button was pressed. 我要在此处开发的内容基于用户单击单选按钮以检查是否按下了正确的单选按钮。 In other words I have a list of radio buttons in my XML and based on the question I want the user to click on the specific radio button in order to proceed to the next question. 换句话说,我在XML中有一个单选按钮列表,基于这个问题,我希望用户单击特定的单选按钮以继续进行下一个问题。 As long as the user clicks on wrong radio buttons, a message is shown as a Toast message saying that the radio button pressed is incorrect, and the tries left. 只要用户单击了错误的单选按钮,就会显示一条消息,作为Toast消息,表明按下的单选按钮不正确,然后尝试返回。 the maximum tries per question is set to 5. This all need to be done without the click of a button. 每个问题的最大尝试次数设置为5。这一切都需要在不单击按钮的情况下完成。 The code is below; 代码如下; if not the right implementation was used in such case (or any recommendations) please let me know 如果在这种情况下(或任何建议)未使用正确的实现方式,请告诉我
public void run(){
int userTries = 0;
while(userTries < 5){
if(leftBack.isChecked()){
Toast.makeText(FootballFindThePosition.this,
"Well Done! \nMoving on!",
Toast.LENGTH_SHORT).show();
userTries = 0;
}
else if(rightBack.isChecked() || cbleft.isChecked() || cbright.isChecked()){
Toast.makeText(FootballFindThePosition.this,
"Please try again!",
Toast.LENGTH_SHORT).show();
userTries++;
}
}
}
The radiobuttons does not belong to a radiogroup (not sure if thats okay) 单选按钮不属于单选组(不确定是否可以)
I think you really want something like this rather than a running thread. 我认为您确实想要这样的东西,而不是运行线程。
http://developer.android.com/guide/topics/ui/controls/checkbox.html http://developer.android.com/guide/topics/ui/controls/checkbox.html
In other words a common method declared in your xml and implemented in your activitity that listens to the individual clicks. 换句话说,在您的xml中声明并在您的活动中实现的一种通用方法,用于监听各个点击。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.