I tried making an app in which after clicking on the button the image in the background changes to the image cat.png . When I run the app, neither the image in the background comes up nor the the image which is supposed to show up in the place of the background image.
Please see the below code and help.
The onClick function for button is newCat.
package com.example.imagelesson;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
public void newCat(View view){
ImageView image = (ImageView)findViewById(R.id.catImgView);
image.setImageResource(R.drawable.cat);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}