我有一个 parsecolor 异常的问题,当我的值低于 20 时,应用程序崩溃,其余的都很好......你能告诉我为什么吗?
我的简单代码是:
公共类 ColoreTesto 扩展 Activity {
private SeekBar seekred, seekgreen, seekblu;
private TextView seekred_txt, seekgreen_txt, seekblu_txt;
private TextView esempio;
private int redtxt, greentxt, blutxt;
private int progressred, progressgreen, progressblu;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.coloretesto);
/* RIFERIMENTO AL GRUPPO DI VARIABILI SHARED*/
final SharedPreferences settings = getSharedPreferences("settings", 0);
final SharedPreferences.Editor editor = settings.edit();
esempio = (TextView)findViewById(R.id.txt_esempio);
/****
* SEEKBAR RED
****/
seekred = (SeekBar) findViewById (R.id.seekRed);
seekred.setMax(255);
seekred_txt = (TextView)findViewById(R.id.textRed);
/*CARICARE IL VALORE DELLA SEEKBAR*/
redtxt = settings.getInt("redtxt", 255); /*UNA VARIABILE DEL GRUPPO*/
seekred_txt.setText(redtxt + getString(R.string.red));
seekred.setProgress(redtxt);
// CAMBIAMENTO DEL VALORE DELLA SEEKBAR
seekred.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
//spostamento
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
seekred_txt.setText(progress + getString(R.string.red));
esempio.setTextColor(Color.parseColor("#" + Integer.toHexString(progress) + Integer.toHexString(greentxt) + Integer.toHexString(blutxt)));
}
//inizio dello spostamento
public void onStartTrackingTouch(SeekBar seekBar) {
}
//fine dello spostamento
public void onStopTrackingTouch(SeekBar seekBar) {
redtxt = seekBar.getProgress();
}
});
/****
* SEEKBAR GREEN
****/
seekgreen = (SeekBar) findViewById (R.id.seekGreen);
seekgreen.setMax(255);
seekgreen_txt = (TextView)findViewById(R.id.textGreen);
/*CARICARE IL VALORE DELLA SEEKBAR*/
greentxt = settings.getInt("greentxt", 255); /*UNA VARIABILE DEL GRUPPO*/
seekgreen_txt.setText(greentxt + getString(R.string.green));
seekgreen.setProgress(greentxt);
// CAMBIAMENTO DEL VALORE DELLA SEEKBAR
seekgreen.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
//spostamento
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
seekgreen_txt.setText(progress + getString(R.string.green));
esempio.setTextColor(Color.parseColor("#" + Integer.toHexString(redtxt) + Integer.toHexString(progress) + Integer.toHexString(blutxt)));
}
//inizio dello spostamento
public void onStartTrackingTouch(SeekBar seekBar) {
}
//fine dello spostamento
public void onStopTrackingTouch(SeekBar seekBar) {
greentxt = seekBar.getProgress();
}
});
/****
* SEEKBAR BLU
****/
seekblu = (SeekBar) findViewById (R.id.seekBlu);
seekblu.setMax(255);
seekblu_txt = (TextView)findViewById(R.id.textBlu);
/*CARICARE IL VALORE DELLA SEEKBAR*/
blutxt = settings.getInt("blutxt", 255); /*UNA VARIABILE DEL GRUPPO*/
seekblu_txt.setText(blutxt + getString(R.string.blu));
seekblu.setProgress(blutxt);
// CAMBIAMENTO DEL VALORE DELLA SEEKBAR
seekblu.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
//spostamento
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
seekblu_txt.setText(progress + getString(R.string.blu));
esempio.setTextColor(Color.parseColor("#" + Integer.toHexString(redtxt) + Integer.toHexString(greentxt) + Integer.toHexString(progress)));
}
//inizio dello spostamento
public void onStartTrackingTouch(SeekBar seekBar) {
}
//fine dello spostamento
public void onStopTrackingTouch(SeekBar seekBar) {
blutxt = seekBar.getProgress();
}
});
}
}
谢谢。