title: Changing the background image of a button on Kotlin
body: <p>I am currently trying to use two buttons, button A and button B. They are on separate activities, and when button B is pressed, the background image on button A should change. So far, here is my relevant code</p>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;Button
          android:id="@+id/button_a"
          android:layout_width="295dp"
          android:layout_height="250dp"
          android:background="@drawable/before_press" /&gt;
  </code></pre>
  
  <p>activity_2.xml</p>
  
  <pre><code> &lt;Button
          android:id="@+id/button_b"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/Button B"
          /&gt;
  </code></pre>
  
  <p>activity_2.kt</p>
  
  <pre><code> button_b.setOnClickListener {
             button_a.setBackgroundResource(R.drawable.after_press)
              val intent = Intent(this, MainActivity::class.java)
              startActivity(intent)
          }
  </code></pre>
  
  <p>I believe it may be something to do with the android:background= being in @drawable form and not R.drawable form, but not sure</p>
  
  <p>I tried many different options and searched this website also</p>
  
  <p>any help would be appreciated!</p>