-3

I'm making a simple app that shows information for a game and decided to use the character avatars as the ImageButton to switch to the page that has information on them, but when they are pressed they do not switch the Activity

The xml for the ImageButton

<ImageButton
    android:id="@+id/GoToMarauder"
    android:layout_width="62dp"
    android:layout_height="66dp"
    app:srcCompat="@mipmap/marauder_avatar"
    app:layout_constraintBottom_toBottomOf="parent"
    android:layout_marginBottom="-4dp"
    app:layout_constraintRight_toLeftOf="@+id/GoToTemplar"
    android:layout_marginRight="86dp" />

The onClick listener

ImageButton GoMarauder;
....
GoMarauder = (ImageButton) findViewById(R.id.GoToMarauder);
.....
GoMarauder.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent GoMarauder = new Intent(Classes.this, Marauder.class);
            startActivity(GoMarauder);
        }
    });
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Jake G
  • 3
  • 3

1 Answers1

0

Make sure you are setting click listener on right Java object, and activity is registered in manifest.

mnp343
  • 329
  • 1
  • 6
  • Do you see any kind of warning in logcat? – mnp343 May 10 '17 at 21:23
  • No but it does say it displayed the activity which it doesnt – Jake G May 10 '17 at 21:25
  • Try logcat in the onCreate() of marauder activity and see if it gets printed. And also take a glance at setcontentview of marauder. – mnp343 May 10 '17 at 21:27
  • Thank you there was a mistake i made in setcontentview i had copy and pasted the on click listeners from another activity so had also done that and the it was opening the page i had come from im quite new to java + android so I've made a lot of mistakes like this. – Jake G May 10 '17 at 21:33