/ Published in: Java
from "Hello Android 2nd Edition" (ISBN: 1-934356-49-2)
Expand |
Embed | Plain Text
package org.example.sudoku; import android.app.Dialog; import android.content.Context; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; private View keypad; private final int useds[]; private final PuzzleView puzzleView; super(context); this.useds = useds; this.puzzleView = puzzleView; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.keypad_title); setContentView(R.layout.keypad); findViews(); for(int element : useds) { if(element != 0) } setListeners(); } private void findViews() { keypad = findViewById(R.id.keypad); keys[0] = findViewById(R.id.keypad_1); keys[1] = findViewById(R.id.keypad_2); keys[2] = findViewById(R.id.keypad_3); keys[3] = findViewById(R.id.keypad_4); keys[4] = findViewById(R.id.keypad_5); keys[5] = findViewById(R.id.keypad_6); keys[6] = findViewById(R.id.keypad_7); keys[7] = findViewById(R.id.keypad_8); keys[8] = findViewById(R.id.keypad_9); } private void setListeners() { for(int i = 0; i < keys.length; i++) { final int t = i + 1; returnResult(t); }}); } returnResult(0); }}); } @Override int tile = 0; switch(keyCode) { default: return super.onKeyDown(keyCode, event); } if(isValid(tile)) { returnResult(tile); } return true; } private boolean isValid(int tile) { for(int t : useds) { if(tile == t) return false; } return true; } /** Return the chosen tile to the caller */ private void returnResult(int tile) { puzzleView.setSelectedTile(tile); dismiss(); } }
Comments
Subscribe to comments
You need to login to post a comment.

The clock in the high church tower struck and the sound made him remember his parents'wow gold sale early love
for him. They had taught him and prayed to God for his good.wow accounts But he chose the wrong way. wow account With shame and glonger look towards that .ghd straighteners His
darkened eyes were full of tears, LVand with a despairing effort, he burst out a cry: "Come back, my early days! Come back!" yy2010.4.7
When i copy paste this into eclipse, why does it show error on lines 28 ( keypad title cannot be resolved ) Also lines 39 though 48? ( keypad cannot be resolved or is not a filed ) Have I missed something?