Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.helloworld;
- import androidx.appcompat.app.AppCompatActivity;
- import androidx.constraintlayout.widget.ConstraintLayout;
- import android.graphics.Color;
- import android.os.Bundle;
- import android.view.View;
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- }
- public void changeColor(View view){
- ConstraintLayout cl = findViewById(R.id.constraintLayout);
- switch(view.getId()){
- case R.id.button1:
- cl.setBackgroundColor(Color.parseColor("#000000"));break;
- case R.id.button2:
- cl.setBackgroundColor(Color.parseColor("#ffffff")); break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement