p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Android 2 Application Development (http://p2p.wrox.com/forumdisplay.php?f=547)
-   -   Needed imports for Chapter 2 To-Do List Example (http://p2p.wrox.com/showthread.php?t=78435)

alex_harding March 4th, 2010 02:25 AM

Needed imports for Chapter 2 To-Do List Example
 
Not sure why the book failed to mention the proper imports needed for the chapter 2 to-do list example to compile correctly. If you're entering the code manually (this chpt. 2 to-do list example code is not available for download), add the following import statements or simply apply the control+shift+o import shortcut in eclipse.

import java.util.ArrayList;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;

Programming Android doesn't have to be like a raging hemorrhoid...

Reto March 6th, 2010 12:20 PM

Hi Alex,
Thanks for contributing the required imports for the Chapter 2 Todo List example. You may have posted this before I posted the code samples online, but the full code for this example (and all the others) should be available from here: http://www.wrox.com/WileyCDA/WroxTit...-DOWNLOAD.html

If that's not the case, please let me know!

The reason I didn't include all the import statements for each example is to try and keep the code as concise as possible. As a 'Professional' title it assumes a certain level of knowledge and experience - in particular I'm hoping that most people using the book know how to use the shortcut you specified to add any required imports.

You make a fair point though - for the next revision I'll explicitly mention the shortcut to try and make peoples lives a little easier.

Thanks for the feedback!

russray March 7th, 2010 09:36 AM

Quote:

Originally Posted by alex_harding (Post 254382)
Not sure why the book failed to mention the proper imports needed for the chapter 2 to-do list example to compile correctly. If you're entering the code manually (this chpt. 2 to-do list example code is not available for download), add the following import statements or simply apply the control+shift+o import shortcut in eclipse.

import java.util.ArrayList;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;

Programming Android doesn't have to be like a raging hemorrhoid...

If you are doing this by hand, you will also need:
import android.os.Bundle;

This is used in your public void onCreate(Bundle savedInstanceState) method. Like the author mentioned, Eclipse will do this for you.

alex_harding March 9th, 2010 02:35 PM

Thanks Reto!
 
Wow, I do appreciate an author that supports the book's user base by being an active and timely participant in these forums. Kudos to you Reto.

Given that the content of this "Professional" book focuses primarily on exploring android-specific functionality available within the packages of the Android SDK, I guess I fail to understand how readers of different development backgrounds would know or "hope" to know what packages to import for the android-specific View objects introduced the Chapter 2 example code. Why have Eclipse bark at you so early on when in later chapters it appears you do a good job in the text to introduce the packages you need to support the added functionality of the To-Do example?

dshinsel March 21st, 2010 02:48 AM

Regarding: "As a 'Professional' title it assumes a certain level of knowledge and experience - in particular I'm hoping that most people using the book know how to use the shortcut you specified to add any required imports."

I am a long term Windows C++ programmer, but new to Android, and therefore Java/Eclipse. So, I agree with other comments; a quick into to Java/Android/Eclipse (or reference section in the back?) would save a lot of grief for those of us coming from different dev systems. Great book, thanks!

P.S. Do you have a recomendation for a book to help C++ developers get started in this environment?

Reto March 21st, 2010 07:18 AM

It's a good point, and something I definitely intend to rectify in the next edition. It seems a couple of pages introducing Eclipse would be extremely useful. Thanks for the feedback!

chuckycjc June 12th, 2010 08:49 PM

Reto,

Take a look at Jeff LaMarche/Dave Mark iPhone 3 Development book. They always provided the necessary imports in the text code (they had a couple of mistakes along the way)

If your book is targeting beginners then its important to provide the necessary detail so the program will run correctly as entered from the text without relying on the source code.

I have some experience with iPhone development and Java and Eclipse helped me determine what was wrong right away. A less experienced programmer could waste alot of time, which would increase the chances of your book ending up in the trash!

Thanks,

donholloway September 19th, 2010 07:57 PM

I needed this one
 
Thanks to everyone for jumping in here. I tried the code twice, but did not know to import these functions.

Also a professional, use Ruby quite a bit, but am relatively new to Java. This was a big help.

fmgerber@verizon.net March 11th, 2011 04:10 PM

Version Depenant ?
 
I have all the right imports showing but have errors on every line of my todo list project from chapter 2. I am running Android 2.1 update. Is this incompatible wit hthe instructions in the book which qare for 2.0 ?

sunilbn March 12th, 2011 08:29 AM

Android API
 
Hi, fmgerber@verizon.net.
Yes some android api's are version dependent, the best solution is to develop the android application for basic version, if you are looking for wide use of your app on any android phone, since there is a upward compatibility. If you get stuck in - what import statements to use, then you can write the entire code first and then make use of eclipse feature(if your using it) of auto-importing the packages by pressing Ctrl+O.
If you still find any problems in todo program, then use Android API 2.2 - the one i used for running my programs. And one more thing the variable names used in main.xml and in your java program has to be same. I hope this helps.


All times are GMT -4. The time now is 01:02 PM.

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