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 December 13th, 2011, 11:47 AM
Registered User
 
Join Date: Dec 2011
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();
                }
            })
 
Old December 13th, 2011, 07:35 PM
Authorized User
 
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.
 
Old December 14th, 2011, 02:32 AM
Registered User
 
Join Date: Dec 2011
Posts: 8
Thanks: 3
Thanked 0 Times in 0 Posts
Default

they are already ic_launcher but still getting error...
 
Old December 14th, 2011, 04:00 PM
Authorized User
 
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.
The Following User Says Thank You to Cliff2310 For This Useful Post:
yazi (December 16th, 2011)
 
Old December 27th, 2011, 03:39 PM
Registered User
 
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)
The Following User Says Thank You to Paulo_Afonso For This Useful Post:
anwarma (January 10th, 2012)
 
Old January 10th, 2012, 11:14 PM
Registered User
 
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?
 
Old January 11th, 2012, 06:20 PM
Registered User
 
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?
The Following User Says Thank You to Gink For This Useful Post:
barcapat (February 15th, 2012)
 
Old January 11th, 2012, 08:01 PM
Authorized User
 
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.
 
Old February 15th, 2012, 11:55 AM
Registered User
 
Join Date: Jul 2007
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.





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





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