1
2.
put this xml into your values folder
Colors.xml
MainActivity.java#d73249 #ffcb00 #fff
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends Activity {
private View start;
private View stop;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
stop = findViewById(R.id.start);
start = findViewById(R.id.stop);
}
public void start(View view) {
stop.setBackgroundResource(R.color.red);
start.setBackgroundResource(R.color.yellow);
}
public void stop(View view) {
stop.setBackgroundResource(R.color.yellow);
start.setBackgroundResource(R.color.red);
}
}
activity_main.xml
You may also like: Style a button in android