Disclaimer: this is a homework assignment so please no direct answers, please point me in the right direcction.
I am trying to create a simple activity that changes between two pictures when the button is clicked. I tried the followoing implementation
package com.example.davidmiller.assignment2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
Integer pic = 0;
ImageView noleID = (ImageView) findViewById(R.id.nolePic);
ImageView gatorID = (ImageView) findViewById(R.id.gatorPic);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void showMe(View view) {
if(pic == 0) {
noleID.setVisibility(View.INVISIBLE);
gatorID.setVisibility(View.VISIBLE);
pic = 1;
}
else {
gatorID.setVisibility(View.INVISIBLE);
noleID.setVisibility(View.VISIBLE);
pic = 0;
}
}
}
However when I try running the activity my emulator says the Assignment2 has stopped working. Any help is appreciated.