안녕 안드로이드 북에는 스도쿠 솔루션이 있습니다. 축하 메시지가 마지막에 표시됩니다. 나는 왼쪽 빈 squareds가 있는지 확인하는 방법이 있고 나는 마지막 입력은 어떤 이유로 광장if 문이 화면을 좌우로 흔들어 놓는 이유는 무엇입니까
/****** Check to see if the game is complete **/
public boolean isSolved() {
for (int element : puzzle) {
if (element == 0)
return false;
}
return true;
}
/** Change the tile only if it's a valid move */
protected boolean setTileIfValid(int x, int y, int value) {
int tiles[] = getUsedTiles(x, y);
if (value != 0) {
for (int tile : tiles) {
if (tile == value)
return false;
}
}
setTile(x, y, value);
calculateUsedTiles();
//check if the game is complete after each valid move
if (isSolved() == true) {
Intent i = new Intent(this, Congratulations.class);
startActivity(i);}
else
{
return false;
}
return true;
}
에 대한 유효한 항목이 있다면 내가 전에 타일을 입력 할 때 확인하는 또 다른 방법으로 그 전화 게임이 완료되면 전체 화면이 좌우로 흔들립니다. 내가 게임 체크를하기 전에는 이렇게하지 않았다. 왜 그리고 어디에서 이렇게하고 있습니까? 화면을 흔들어에 대한 책임을 일부 애니메이션이처럼
Congratulatons.xml <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dip" > <TextView android:id="@+id/about_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/congratulations_text" /> </ScrollView>
Congratulations.java
package com.example.sudoku;
import android.app.Activity;
import android.os.Bundle;
public class Congratulations extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.congratulations);
}
}