21 Mar 2010, 18:19

Paul Lucas (8 posts)

Hello, first of all i would just like to say this book is very good and straight forward so thanks for that. Now for the questions

1) I am very interested in developing for android because i love the os and it seems like it will be continually growing for a while, but the bad thing is that ive never coded in java (really ive barley done any coding at all). So i bought this book to help me with the android side but i need a suggestion to get me going on the java side because reading this book i have no clue what a lot of the code is doing or how to write the syntax for that. So any suggestions for java books to get me to start to understand it?

2) Also ive been going through the book and i just finished chapter 4. When i run the code, everything works, except in the game, after everything draws successfully, if i click on any square, the program receives an error. I thought about posting the error but it doesnt make any sense to me so i am just gunna post my whole project and hopefully someone can run this and let me know what i did wrong. Here are the project files - http://rapidshare.com/files/366370214/Sudoku.zip.html

Thanks for the help!

21 Mar 2010, 23:39

Ed Burnette (1329 posts)

Thanks for your kind words. If you could take a minute or two to write a review on Amazon that would be greatly appreciated.

Here are the answers to your questions:

  1. For suggestions on a Java/Eclipse book or tutorial, check out this thread:


I also wrote a little book on Eclipse you might like:


  1. The problem is that in res/layout/keypad.xml you used a LinearLayout when you should have used a TableLayout.

In case anybody else runs into trouble, here’s how I figured it out: I narrowed down the problem by running your version and looking in the LogCat view (Window > Show View > Other > Android > LogCat). I saw this:

03-21 22:29:15.133: ERROR/AndroidRuntime(212): java.lang.RuntimeException: Binary XML file line #9: You must supply a layout_width attribute.
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:438)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:3433)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:3513)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1265)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1191)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:45)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:313)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at android.app.Dialog.setContentView(Dialog.java:421)
03-21 22:29:15.133: ERROR/AndroidRuntime(212):     at org.example.sudoku.Keypad.onCreate(Keypad.java:31)

That sent me to line #9 of keypad.xml which is:


TableRow is supposed to be used in a TableLayout, but I noticed that on line 2 of the same file you’re using a LinearLayout. Case closed.

By the way, the error about layout_width is a little misleading here, but it happens because all the children of LinearLayout must have a layout_width. The children of TableLayout don’t need that because TableLayout can set their widths for them.

Good luck, –Ed

21 Mar 2010, 23:52

Paul Lucas (8 posts)

I hope this isnt a stupid question, but how did you know it had to be in the keypad.xml file and not any of the other ones? Just because of the fact that it occurred only while opening the keypad? But thanks so much for that help, this book was especially worth the money because of this added support.

I will write a review shortly on amazon, and thanks for the tips on the books. Im looking into getting that pocket guide right now because of how handy it looks

22 Mar 2010, 02:02

Ed Burnette (1329 posts)

It’s not a stupid question. I had two clues. The first was that you only got it when opening the keypad. The other was in the log file, on this line:

    at org.example.sudoku.Keypad.onCreate(Keypad.java:31)

If you look at Keypad.java line 31 (open Keypad.java, press Ctrl+L, type 31) you see:


R.layout.keypad refers to the res/layout/keypad.xml file.

Oh, I forgot to mention dzone.com has a reference card that I did with Adam Houghton. Here’s the link:


That one has a lot of nice keyboard shortcuts, and it’s free!

  You must be logged in to comment