Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy does an if statement shake the screen from side to side
    text
    copied!<p>In the hello android book there is a Sudoku solution. I wanted to create a message at the end that displays a dialog saying congratulations. I have a method to check if there are any empty squareds left and I call that in another method that checks if the last input was a valid entry for the square</p> <pre><code>/****** 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; } </code></pre> <p>For some reason when i enter a tile before the game is complete the whole screen shakes from side to side. This did not do this before I entered the checking of the game. Why and where is it doing this?</p> <p>Congratulatons.xml <code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dip" &gt; &lt;TextView android:id="@+id/about_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/congratulations_text" /&gt; &lt;/ScrollView&gt; </code> Congratulations.java</p> <pre><code>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); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload