我要确认至少选中了一个复选框。下面是我正在使用的代码。
public classGejalaKariesGigiActivityextendsAppCompatActivity {
Intent intentData;
Button buttonSend;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gejala_karies_gigi);
intentData = new Intent(GejalaKariesGigiActivity.this,HasilDiagnosaActivity.class);
buttonSend = (Button) findViewById(R.id.buttonselesai1);
buttonSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(intentData);
}
});
}
public void selectItem(View view){
boolean checked = ((CheckBox) view).isChecked();
switch (view.getId()) {
case R.id.checkBoxgigiberlubang:if (checked){
intentData.putExtra("gigi_berlubang","Gigi Berlubang");
}else {
intentData.removeExtra("gigi_berlubang");
}break;
case R.id.checkBoxngilu:if (checked){
intentData.putExtra("ngilu","Ngilu");
}else {
intentData.removeExtra("ngilu");
}break;
case R.id.checkBoxadabercak:if (checked){
intentData.putExtra("ada_bercak_hitam_pada_gigi","Ada Bercak Hitam Pada Gigi");
}else {
intentData.removeExtra("ada_bercak_hitam_pada_gigi");
}break;
default:break;
}
}
}
答案 0 :(得分:0)
您必须在if else语句中选中每个复选框。
try
{
BufferedImage original = ImageIO.read(OriginalImage);
BufferedImage resized = new BufferedImage(width, null, original.getType());
Graphics2D g2 = resized.createGraphics();
g2.drawImage(original, 0, 0, width, null, null);
g2.dispose();
ImageIO.write(resized, format, resizedImage);
}