我不知道为什么,但是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++;
}
}发布于 2016-03-02 07:18:16
必须首先创建onCreate方法..。然后将代码添加到其中。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.yourActivity);
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++;
}
}https://stackoverflow.com/questions/35740539
复制相似问题