Skip to content

Instantly share code, notes, and snippets.

@chrishuan9
Created April 28, 2012 07:42
Show Gist options
  • Save chrishuan9/2516930 to your computer and use it in GitHub Desktop.
Save chrishuan9/2516930 to your computer and use it in GitHub Desktop.
GameView
public class LudoActivity extends Activity implements OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
FrameLayout Game = new FrameLayout(this);
GameView Gameview = new GameView (this);
LinearLayout GameWidgets = new LinearLayout (this);
Button EndGameButton = new Button(this);
TextView MyText = new TextView(this);
EndGameButton.setWidth(300);
EndGameButton.setText("Start Game");
MyText.setText("rIZ..i");
GameWidgets.addView(MyText);
GameWidgets.addView(EndGameButton);
Game.addView(Gameview);
Game.addView(GameWidgets);
setContentView(Game);
EndGameButton.setOnClickListener(this);
}
public void onClick(View v) {
Intent intent = new Intent(this, LudoActivity.class);
startActivity(intent);
// re-starts this activity from game-view. add this.finish(); to remove from stack
}
}
//GameView:
public class GameView extends SurfaceView {
public GameView(Context context) {
super(context);
/*
* your code
*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment