Wrox Programmer Forums
|
BOOK: Beginning Android Application Development
This is the forum to discuss the Wrox book Beginning Android Application Development by Wei-Meng Lee; ISBN: 978-1-1180-1711-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2011, 07:15 PM
Authorized User
 
Join Date: Nov 2011
Posts: 86
Thanks: 3
Thanked 5 Times in 5 Posts
Default Chapter 2 Dialog problem undifend vars

I have entered the code and fixed the typos (I think) and there three errors left.
In main.xlm
andriod:id="@+id/btn_dialog" R.id is not defined
In DialogActivity.java
Button btn = (Button) findViewById(R.id.btn_dialog);
R.id is not defined
.setIcon(R.drawable.icon) icon in not defined.
Target is 2.3.3, Running on Windows XP.
Any help with where these should be defined would be appreciated.
Thanks
Cliff
__________________
"Software to the Stars"
Failure is not an option. It comes bundled with your Microsoft products.
 
Old November 4th, 2011, 03:58 PM
Authorized User
 
Join Date: Oct 2011
Posts: 10
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Without seeing everything you have typed in each file (and I don't really want to do that) I can make a couple of suggestions, but they may not work.

Firstly, I found that I was getting a number of similar errors and that one way to solve some of them was to delete the generated file R.java and let it be automatically rebuilt.

Another possible suggestion is to look at lines of code before, sometimes many, many lines before, the one that seems to be causing the problem and see if you have added a semi-colon, < or some other punctuation mark.

A third, but in this case less likely solution, is to check import statments.

Can you say which page the project you are working on is from?
 
Old November 4th, 2011, 04:30 PM
Registered User
 
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm also having a similar issue with the downloaded code "Dialog" from chapter 2.

code: .setIcon(R.drawable.icon)

Eclipse says that icon is undefined.
 
Old November 4th, 2011, 07:04 PM
Authorized User
 
Join Date: Nov 2011
Posts: 86
Thanks: 3
Thanked 5 Times in 5 Posts
Default more

Hi All
First thanks for the replies.
Tave,
1) I have looked very carefully and I see no other errors, but I am not a expert in Java. The only errors shown are those I listed.
2) I did delete R. When I run the code it says to fix the errors first. No new R. is generated. Is there a way to force the regeneration of R?
3) I have checked the Import statements and they appear to be correct. I did originally find one missing and added it but haven't been able to get R. regenerated( see 2).
I'm sure that the problem is with my inexperience with Eclipse and Java. I just don't know what to look for.
I'll post the code if anyone thinks they want to look at it.
Thanks for your time
Cliff
__________________
"Software to the Stars"
Failure is not an option. It comes bundled with your Microsoft products.
 
Old November 6th, 2011, 02:33 PM
Authorized User
 
Join Date: Nov 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had the same problem with 'icon' being undefined in Eclipse. The complete downloaded code seemed to work ok, but not if you type it in. Eclipse suggests using 'ic_launcher' instead of 'icon' and that seems to work.
 
Old November 19th, 2011, 11:04 AM
Registered User
 
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with icon

I had the same problem with "undefined" icon. I've found a solution somewhere in internet:
The file icon.png must be placed in res/drawable-mdpi directory and error disappears.
 
Old November 20th, 2011, 02:25 AM
Registered User
 
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, Eclipse has/had such issues mentioned above. I suggest update ADT plugin to latest build version from Help > Check for Updates.

And answer to Cliff2310:
to resolve such a "Unrecognised Variable" problems, Delete R.java from "gen" directory and save the project. Eclipse should auto generate another clean R.java
 
Old November 20th, 2011, 07:33 PM
Authorized User
 
Join Date: Nov 2011
Posts: 86
Thanks: 3
Thanked 5 Times in 5 Posts
Default Problem solved

Hi All
Thanks for all the responses. Most of my problem was being unfamiliar with Eclipse and how it did things.
Cliff
__________________
"Software to the Stars"
Failure is not an option. It comes bundled with your Microsoft products.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter-17 TryITout..Adding and Using an open file Dialog raghavraam BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 0 July 17th, 2009 02:12 AM
Insert New Row from Session Vars iceandrews VB Databases Basics 1 May 12th, 2008 08:16 AM
Security: Could someone falsificate session vars? Maxxim ASP.NET 2.0 Professional 5 February 13th, 2008 12:06 PM
Chapter 17 - Displaying the dialog box davidd31415 BOOK: Beginning Visual C++ 6 1 September 24th, 2006 04:46 PM
passing vars cassius_b C# 1 July 17th, 2006 07:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.