Last active
December 29, 2015 06:49
-
-
Save Bapho/7631926 to your computer and use it in GitHub Desktop.
This is the on-click button listener for the start activity. -three-day project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.baphoware.prjhelloween.listener; | |
import com.baphoware.prjhelloween.R; | |
import com.baphoware.prjhelloween.activities.GameActivity; | |
import com.baphoware.prjhelloween.activities.HelloWeenActivity; | |
import android.content.Intent; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
public class HelloWeenActivityOnClickListener implements OnClickListener | |
{ | |
// Intent deklarieren | |
private Intent intentGame = null; | |
public HelloWeenActivityOnClickListener() | |
{ | |
// standard constructor | |
} | |
@Override | |
public void onClick( View v ) | |
{ | |
// Fallprüfung | |
switch( v.getId() ) | |
{ | |
case R.id.cmdStart: | |
// Intent initialisieren | |
intentGame = new Intent( v.getContext(), GameActivity.class ); | |
// Activity starten, wenn der Intent nicht "null" ist | |
if( intentGame != null ) | |
{ | |
v.getContext().startActivity( intentGame ); | |
} | |
break; | |
// beenden | |
case R.id.cmdExit: | |
// CAST view.-context to MainActivity EXPLIZITER CAST | |
HelloWeenActivity gameActivity = (HelloWeenActivity) v.getContext(); | |
gameActivity.finish(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment