A.Schtolc A.Schtolc - 1 year ago 41
Android Question

How to change the picture in ImageView by clicking button?

There is one button in my app, which changes content on screen. Can I make this button change picuture in ImageView from array with pictures by clicking it?

Answer Source
Button yourButton = (Button) findViewById(R.id.yourButton);
    final int[] images = {
    yourButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            ImageView yourImageView = (ImageView) findViewById(R.id.imageView2);

This is one sulotion. Replace "yourButton" and "yourImageView" with your elements.

(Code not tested yet) Hope that helps!