ImageButton change src

android, imagebutton

Solution

Because `android:src` and `android:background` is the different attributes. You should use

button.setImageResource(R.drawable.save);

Problem

Change the ImageButton src Here is the xml for the tag: ``` <ImageButton android:layout_width="0dp" android:id="@+id/infobutton" android:layout_weight="1" android:src="@drawable/edit" android:scaleType="fitCenter" android:layout_height="60dp" /> ``` This is what im doing to the button when it get pressed ``` button.setBackgroundResource(R.drawable.save); ``` The ImageButton before pressed Image after press: I want the button to only have the save Picture and it beeing fitCenter and why doesnt the other src get replaced With the New src?

Original source

Related problems