I got one Alretdialog with an EditText and a Seekbar. By using the Seekbar, i want to change the background color of my edittext.
Changing the seekbar color works, but not changing the edittext background color.
EditText newSubjectEdit;
SeekBar colorSeeker;
Builder subjectAlert;
LinearLayout lg;
private Builder getNewSubjectAlert() {
subjectAlert = new AlertDialog.Builder(this);
lg = new LinearLayout(getApplicationContext());
...
newSubjectEdit = new EditText(getApplicationContext());
...
lg.addView(newSubjectEdit);
colorSeeker = new SeekBar(getApplicationContext());
colorSeeker.setOnSeekBarChangeListener(seekBarChangeListener);
...
lg.addView(colorSeeker);
subjectAlert.setView(lg);
// set ok and cancel ...
the listener:
SeekBar.OnSeekBarChangeListener seekBarChangeListener = new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
seekBar.setBackgroundColor(color); // works !!
newSubjectEdit.setBackgroundColor(color); // doesn't work
}
};
hope you understand what i mean…
ifound prob.as you have add view dynamicalle.newSubjectEdit called more than once.so it is overridden.and for seekbar seekbar.OnSeekBarChangeListener gives you seekbar as arg. which is referenced.so it gives correct object