 |
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
|
|
|
|

December 13th, 2011, 11:47 AM
|
|
Registered User
|
|
Join Date: Dec 2011
Posts: 8
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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();
}
})
|
|

December 13th, 2011, 07:35 PM
|
|
Authorized User
|
|
Join Date: Nov 2011
Posts: 86
Thanks: 3
Thanked 5 Times in 5 Posts
|
|
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.
|
|

December 14th, 2011, 02:32 AM
|
|
Registered User
|
|
Join Date: Dec 2011
Posts: 8
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
they are already ic_launcher but still getting error...
|
|

December 14th, 2011, 04:00 PM
|
|
Authorized User
|
|
Join Date: Nov 2011
Posts: 86
Thanks: 3
Thanked 5 Times in 5 Posts
|
|
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)
|
|

December 27th, 2011, 03:39 PM
|
|
Registered User
|
|
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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:
|
|
|

January 10th, 2012, 11:14 PM
|
|
Registered User
|
|
Join Date: Jan 2012
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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?
|
|

January 11th, 2012, 06:20 PM
|
|
Registered User
|
|
Join Date: Jan 2012
Posts: 4
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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:
|
|
|

January 11th, 2012, 08:01 PM
|
|
Authorized User
|
|
Join Date: Nov 2011
Posts: 86
Thanks: 3
Thanked 5 Times in 5 Posts
|
|
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.
|
|

February 15th, 2012, 11:55 AM
|
|
Registered User
|
|
Join Date: Jul 2007
Posts: 2
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
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.
|
|
 |
|