它在模拟器中完美运行,但在设备上每次按下RadioButton时都会崩溃,因此在RadioButton之后的部分代码中必定会出现一些错误,但我找不到它。
public void onRadioButtonClicked(View view) {
DecimalFormat df = new DecimalFormat("##.##");
final EditText min_odds = (EditText) findViewById(R.id.min_odds);
final EditText probability_home = (EditText) findViewById(R.id.probability_home);
final EditText probability_draw = (EditText) findViewById(R.id.probability_draw);
final EditText probability_away = (EditText) findViewById(R.id.probability_away);
double verjetnost = 0;
final double koeficient;
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch(view.getId()) {
case R.id.homewin:
if (checked)
verjetnost= Double.valueOf(probability_home.getText().toString());
koeficient = 1/verjetnost*100;
min_odds.setText(String.valueOf((df.format(koeficient))));
break;
case R.id.drawdraw:
if (checked)
verjetnost= Double.valueOf(probability_draw.getText().toString());
koeficient = 1/verjetnost*100;
min_odds.setText(String.valueOf((df.format(koeficient))));
break;
case R.id.awaywin:
if (checked)
verjetnost= Double.valueOf(probability_away.getText().toString());
koeficient = 1/verjetnost*100;
min_odds.setText(String.valueOf((df.format(koeficient))));
break;
}
按下RadioButton时,我在Logcat上遇到此错误:
02-02 05:37:18.265: E/SoundPool(372): error loading /system/media/audio/ui/Effect_Tick.ogg
02-02 05:37:18.265: W/AudioService(372): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
02-02 05:37:18.275: E/SoundPool(372): error loading /system/media/audio/ui/Effect_Tick.ogg
02-02 05:37:18.275: W/AudioService(372): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
02-02 05:37:18.275: E/SoundPool(372): error loading /system/media/audio/ui/Effect_Tick.ogg
02-02 05:37:18.275: W/AudioService(372): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
02-02 05:37:18.275: E/SoundPool(372): error loading /system/media/audio/ui/Effect_Tick.ogg
02-02 05:37:18.275: W/AudioService(372): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
02-02 05:37:18.275: E/SoundPool(372): error loading /system/media/audio/ui/Effect_Tick.ogg
02-02 05:37:18.275: W/AudioService(372): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
02-02 05:37:18.355: E/SoundPool(372): error loading /system/media/audio/ui/KeypressStandard.ogg
02-02 05:37:18.355: W/AudioService(372): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
02-02 05:37:18.375: E/SoundPool(372): error loading /system/media/audio/ui/KeypressSpacebar.ogg
02-02 05:37:18.375: W/AudioService(372): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
02-02 05:37:18.385: E/SoundPool(372): error loading /system/media/audio/ui/KeypressDelete.ogg
02-02 05:37:18.405: W/AudioService(372): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
02-02 05:37:18.435: E/SoundPool(372): error loading /system/media/audio/ui/KeypressReturn.ogg
02-02 05:37:18.455: W/AudioService(372): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
02-02 05:37:18.495: E/SoundPool(372): error loading /system/media/audio/ui/KeypressInvalid.ogg
02-02 05:37:18.495: W/AudioService(372): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg
02-02 05:37:18.495: W/AudioService(372): onLoadSoundEffects(), Error -1 while loading samples
我有与之前两个活动相同的错误,但应用程序没有崩溃,所以这不是问题。但我在LogCat中没有任何其他错误或例外。
找到错误的其他方法吗?