class suspect : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_suspect)
imagebutton.setOnClickListener {
imagebutton.setImageResource(R.drawable.picture2)
}
}
}
You could save an image identifier to Shared Preferences and then retrieve an image number from Shared Preferences when you open your activity. Then you use that number to set the ImageButton image.
I haven't ran this code, but something along the lines of this should work: