Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Starting a new game

  • Loading branch information...
commit 481e6b8fed997d417882891b0ba6a5f84c7a5cd0 1 parent b704ac7
Carlos Kozuszko authored
View
8 res/values/arrays.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <array name="difficulty">
+ <item>@string/easy_label</item>
+ <item>@string/medium_label</item>
+ <item>@string/hard_label</item>
+ </array>
+</resources>
View
4 res/values/strings.xml
@@ -17,4 +17,8 @@ Sudoku is a logic-based number placement puzzle. Starting with a partially compl
<string name="music_summary">Play background music</string>
<string name="hints_title">Hints</string>
<string name="hints_summary">Show hints during play</string>
+ <string name="new_game_title">Difficulty</string>
+ <string name="easy_label">Easy</string>
+ <string name="medium_label">Medium</string>
+ <string name="hard_label">Hard</string>
</resources>
View
22 src/com/insignia4u/sudokum/Sudoku.mirah
@@ -11,6 +11,11 @@ import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
+import android.app.AlertDialog
+import android.app.AlertDialog.Builder
+import android.content.DialogInterface
+import android.util.Log
+
class Sudoku < Activity
def onCreate(state)
@@ -23,7 +28,9 @@ class Sudoku < Activity
continueButton.setOnClickListener{|v| nil }
newButton = findViewById(R.id.new_button)
- newButton.setOnClickListener{|v| nil }
+ newButton.setOnClickListener do |v|
+ this.openNewGameDialog
+ end
aboutButton = findViewById(R.id.about_button)
aboutButton.setOnClickListener do |v|
@@ -49,4 +56,17 @@ class Sudoku < Activity
false
end
+ def openNewGameDialog
+ dialog = AlertDialog.Builder.new(self)
+ dialog.setTitle R.string.new_game_title
+ this = self
+ dialog.setItems(R.array.difficulty) do |dialogInterface, i|
+ this.start(i)
+ end
+ dialog.show
+ end
+
+ def start(i:int)
+ Log.i "openNewGameDialog", ">>>>>> this is the implementation: #{i}"
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.