이것은 매우 간단한 프로그램입니다. 지금은 간단하게 유지하십시오. 개념은 간단합니다. 모델 건물에서 널리 사용되는 다양한 비늘에 대한 라디오 버튼이 있습니다. 해당 라디오 버튼을 클릭하고 실제 크기를 인치로 입력 한 다음 계산을 누르면 인치로 표시됩니다. 단순한 부서지만, 일할 수만 있다면 필요한 정보를 얻을 수 있습니다. 지금까지는 깔끔하게 컴파일되고 라디오 버튼을 확인하고 숫자를 입력 한 다음 계산 버튼을 누르면 아무 것도하지 않습니다. 다음은 내가 추가 한 코드입니다 (물론 수입은 포함되지 않습니다).오류가없고 프로그램이 실행되지만 절대적으로 않습니다. JACK
public void onButtonClick(View v)
{
int n1, result = 0;
EditText e1 = (EditText)findViewById(R.id.editTextSize);
TextView t1 = (TextView)findViewById(R.id.textView3);
RadioButton rb144 = (RadioButton)findViewById(R.id.radioButton144);
RadioButton rb72 = (RadioButton)findViewById(R.id.radioButton72);
RadioButton rb48 = (RadioButton)findViewById(R.id.radioButton48);
RadioButton rb35 = (RadioButton)findViewById(R.id.radioButton35);
RadioButton rb32 = (RadioButton)findViewById(R.id.radioButton32);
RadioButton rb25 = (RadioButton)findViewById(R.id.radioButton25);
RadioButton rb24 = (RadioButton)findViewById(R.id.radioButton24);
n1 = Integer.parseInt(e1.getText().toString());
if(rb144.isChecked()){
result = n1/144;
}else if(rb72.isChecked()){
result = n1/72;
}else if(rb48.isChecked()){
result = n1/48;
}else if(rb35.isChecked()){
result = n1/35;
}else if(rb32.isChecked()){
result = n1/32;
}else if(rb25.isChecked()){
result = n1/25;
}else if(rb24.isChecked()){
result = n1/24;
}
t1.setText(Integer.toString(result));
쪽지 : 정수 나누기. –
들어가는 진정한 가치는 무엇입니까? 어떤 라디오 버튼이 설정되어 있습니까? – paxdiablo
onButtonClick() 메서드를 호출하는 코드 게시 –