【发布时间】:2016-06-14 21:52:37
【问题描述】:
我不知道为什么,但是isChecked() 不起作用,它说它无法解析符号。有什么我应该进口的吗?我还想问您如何更改Textview 中的文字谢谢!
package xyz.ashraf.whoisdelasalle;
import android.view.View;
import android.widget.CheckBox;
/**
* Created by Ashraf on 3/2/2016.
*/
public class check_Button extends Pop_sallian{
CheckBox concern = (CheckBox) findViewById(R.id.concern);
CheckBox faith = (CheckBox) findViewById(R.id.faith);
CheckBox respect = (CheckBox) findViewById(R.id.respect);
CheckBox education = (CheckBox) findViewById(R.id.education);
CheckBox community = (CheckBox) findViewById(R.id.community);
int con = 0;
int fai = 0;
int res = 0;
int edu = 0;
int com = 0;
if (concern.isChecked()) {
con++;
}
if (faith.isChecked()) {
fai++;
}
if(respect.isChecked()){
res++;
}
if(education.isChecked()){
edu++;
}
if(community.isChecked()){
com++;
}
}
【问题讨论】:
-
哦,你做错地方了
-
覆盖 oncreate 方法并在该方法中执行
-
您不能在类的主体中编写逻辑代码。你的方法声明在哪里?
-
你能写一个解释它的答案吗?