Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 13th, 2011, 11:47 AM
Registered User
Points: 31, Level: 1
Points: 31, Level: 1 Points: 31, Level: 1 Points: 31, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Location: Pakistan
Posts: 8
Thanks: 3
Thanked 0 Times in 0 Posts
Question Ch # 2 Dialog coding error

First I wrote all this code from book but still error then I copied from www.wrox.com still same error and I made that word bold so please guide me...

Code:
@Override
    protected Dialog onCreateDialog(int id) { 
        switch (id) {
        case 0:        	
        	return new AlertDialog.Builder(this)
        	.setIcon(R.drawable.icon) //getting error here on "icon"
            .setTitle("This is a dialog with some simple text...")
            .setPositiveButton("OK", new 
                DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, 
                int whichButton) 
                {
                	Toast.makeText(getBaseContext(), 
                		 "OK clicked!", Toast.LENGTH_SHORT).show();
                }
            })
Reply With Quote
  #2 (permalink)  
Old December 13th, 2011, 07:35 PM
Authorized User
Points: 343, Level: 6
Points: 343, Level: 6 Points: 343, Level: 6 Points: 343, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 86
Thanks: 3
Thanked 5 Times in 5 Posts
Default icon problems

Hi Yazi
Icon some times works and some times it does not. Change it to 'ic_launcher'. This works all the time. This is the file name found under 'res/drawable-?dpi'.
It is the icon that appears on the android device.
Hope this Helps
Cliff
__________________
"Software to the Stars"
Failure is not an option. It comes bundled with your Microsoft products.
Reply With Quote
  #3 (permalink)  
Old December 14th, 2011, 02:32 AM
Registered User
Points: 31, Level: 1
Points: 31, Level: 1 Points: 31, Level: 1 Points: 31, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Location: Pakistan
Posts: 8
Thanks: 3
Thanked 0 Times in 0 Posts
Default

they are already ic_launcher but still getting error...
Reply With Quote
  #4 (permalink)  
Old December 14th, 2011, 04:00 PM
Authorized User
Points: 343, Level: 6
Points: 343, Level: 6 Points: 343, Level: 6 Points: 343, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 86
Thanks: 3
Thanked 5 Times in 5 Posts
Default icon problems 2

Hi Yazi
Sorry, I was unclear. Change 'icon' to 'ic_launcher'.
Like this:
.setIcon(R.drawable.ic_launcher)

Cliff
__________________
"Software to the Stars"
Failure is not an option. It comes bundled with your Microsoft products.
Reply With Quote
The Following User Says Thank You to Cliff2310 For This Useful Post:
yazi (December 16th, 2011)
  #5 (permalink)  
Old December 27th, 2011, 03:39 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Yazi!!

When you are writing the code "R.drawable." , press Ctrl+space. Then is only choose the icon name which will go appear. Try it.
Hope this helps.

Paulo_Afonso (Brazil)
Reply With Quote
The Following User Says Thank You to Paulo_Afonso For This Useful Post:
anwarma (January 10th, 2012)
  #6 (permalink)  
Old January 10th, 2012, 11:14 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2012
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I tried what Paulo_Afonso suggested last but I only found

case 0:
return new AlertDialog.Builder(this)
.setIcon(R.drawable.ic_launcher) '---no icon

Another error is cannot get rid off is ItemsChecked

.setMultiChoiceItems(items, itemsChecked, new
DialogInterface.OnMultiChoiceClickListener() {


Any Ideas?
Reply With Quote
  #7 (permalink)  
Old January 11th, 2012, 06:20 PM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2012
Posts: 4
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Seems like you are misunderstanding mate...

You want to change where you have "icons" typed into your code to be "ic_launcher"

the code is calling for the png file found in the res/layout/drawable folders, which used to be icon.png but has been changed in new versions to ic_launcher.png, so you need to change your code to match that. Anywhere in the code throughout the book that you see "R.drawable.icon" you need to instead type "R.drawable.ic_launcher"

Paulo_Alfonso's suggestion is a good way to go, as the menu it brings up will only list the available resources, so choosing from it keeps you from entering something that doesn't exist...

Hopefully that gets you pointed back in the right direction?
Reply With Quote
The Following User Says Thank You to Gink For This Useful Post:
barcapat (February 15th, 2012)
  #8 (permalink)  
Old January 11th, 2012, 08:01 PM
Authorized User
Points: 343, Level: 6
Points: 343, Level: 6 Points: 343, Level: 6 Points: 343, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 86
Thanks: 3
Thanked 5 Times in 5 Posts
Default

Hi Yazi
For the ItemsChecked error. Do you have the following lines of code?
[code]
public class DialogActivity extends Activity {
CharSequence[] items = {"Sun", "Apple", "Microsoft" };
boolean[] itemChecked = new boolean [items.length];
[\code]
Cliff
PS If you have the 'boolean itemChecked...' post the error you are getting.
__________________
"Software to the Stars"
Failure is not an option. It comes bundled with your Microsoft products.
Reply With Quote
  #9 (permalink)  
Old February 15th, 2012, 11:55 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2007
Location: London, UK.
Posts: 2
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Thanks for the solution to this problem using icon and the explanation for the problem. Now can use the Ctrl-Space to see what comes up if get similar problems and also know to check the folders for relevant files.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
about coding error santosh kumar roy ADO.NET 4 February 13th, 2012 05:47 AM
Error in loginpage coding iswandi2011 Visual Studio 2005 0 August 26th, 2011 03:02 PM
Coding error in the book Mohammad Rastkar BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 April 27th, 2009 02:51 AM
coding problem in common dialog box cancertropica Visual Basic 2005 Basics 0 July 30th, 2008 09:38 AM
All Array is not returning [Coding Error] vinod_yadav1919 Javascript How-To 0 January 18th, 2005 10:10 AM



All times are GMT -4. The time now is 09:03 AM.


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