- 编辑此块中的主要代码 -
我正在编写的此代码在启动时出现问题。它启动应用程序 GUI 并显示“我们很抱歉,“Appname”已不幸停止工作。”
[这里是 logcat 错误][1]
我猜它与这里的启动代码有关:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dhd);
DialogPreference dp = (DialogPreference) findPreference("mediavolume");
dp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference,
Object newValue) {
SeekBar volumeBar = (SeekBar) findViewById(R.id.seekBar);
final AudioManager manager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
volumeBar.setMax(manager
.getStreamMaxVolume(AudioManager.STREAM_SYSTEM));
volumeBar.setProgress(manager
.getStreamVolume(AudioManager.STREAM_SYSTEM));
volumeBar
.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
Toast.makeText(volman.this, "Starting", Toast.LENGTH_LONG).show();
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
Toast.makeText(volman.this, "Now Stopping", Toast.LENGTH_LONG).show();
}
public void onProgressChanged(SeekBar seekBar,
int progress, boolean fromUser) {
manager.setStreamVolume(
AudioManager.STREAM_SYSTEM, progress,
AudioManager.FLAG_SHOW_UI);
Toast.makeText(volman.this, "Now going Silent", Toast.LENGTH_LONG).show();
}
});
return false;
}
});
}
private DialogPreference findPreference(String string) {
return null;
}
}