I have a button that is has:
.setClickable(false);
and
.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
upon initialization.
I then wait for a GPS signal and when one is found, i set setClickable 开发者_StackOverflowto true and the ColorFilter to null. This does work, but does not update the button unless the screen is touched anywhere.
I am certain that this not some loop error in the GPS code because once this button is then pressed, another is set to become clickable and the filter to null, yet the exact same thing happens.
Anyone ever experienced this before? It happens in both 2.2 and 2.3
Heres a sample of the actionlistener of the button:
setgps1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(!gps1set)
{
gps1set = true;
setgps1.setText("Reset");
latitude1.setText(latitude1.getText()+ " +/-"+gpsaccuracy+"m");
longitude1.setText(longitude1.getText()+ " +/-"+gpsaccuracy+"m");
altitude1.setText(altitude1.getText() + " +/-"+gpsaccuracy+"m");
latitude1.setTextColor(Color.GREEN);
longitude1.setTextColor(Color.GREEN);
altitude1.setTextColor(Color.GREEN);
save.setClickable(true);
save.getBackground().setColorFilter(null);
}
else
{
gps1set = false;
setgps1.setText("Set GPS 1");
latitude1.setText(""+lat1);
longitude1.setText(""+lon1);
altitude1.setText(""+alt);
latitude1.setTextColor(Color.WHITE);
longitude1.setTextColor(Color.WHITE);
altitude1.setTextColor(Color.WHITE);
save.setClickable(false);
save.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
}
}
});
If anyone arrived here... you have to call:
save.invalidateSelf();
after changing the background in newer apis.
精彩评论