Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2
This is the forum to discuss the Wrox book Professional Android Application Development by Reto Meier; ISBN: 9780470344712
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 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 February 19th, 2009, 10:03 PM
Registered User
 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Issues with Chapter 2 Todo List .add() on key listener

I had a few errors and realized that they were due to missing imports. But after that I got down to one error.

Code:
myListView.setAdapter(aa);
        
        myEditText.setOnKeyListener(new OnKeyListener() {
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (event.getAction() == KeyEvent.ACTION_DOWN)
                {
                    todoItems.add(0, myEditText.getText().toString());
                    aa.notifyDataSetChanged();
                    myEditText.setText("");
                    return true;
                }
                return false;
            }
        });
LINE:
todoItems.add(0, myEditText.getText().toString());

ERROR:
The method add(int, R.string) in the type ArrayList<R.string> is not applicable for the arguments (int, String) ToDoList.java Todo_List/src/com/paad/todolist line 36 Java Problem

... Any ideas?

I copied the sample code directly into eclipse and the error still appears.
I am using the latest SDK 1.1 and Eclipse 3.4 to develop with.
Reply With Quote
  #2 (permalink)  
Old February 20th, 2009, 02:37 AM
Reto's Avatar
Wrox Author
Points: 287, Level: 5
Points: 287, Level: 5 Points: 287, Level: 5 Points: 287, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2008
Location: London, United Kingdom
Posts: 61
Thanks: 1
Thanked 7 Times in 6 Posts
Default

From the error message it looks like the ArrayList "todoItems" has been declared using the type R.String instead of String.

Just above the code you pasted there are two lines that initialize the generic ArrayList and ArrayAdapter classes, it seems like they might be specifying the type as R.String rather than String. If that's the case you're code might look like this:
Code:
final ArrayList<R.String> todoItems  = new ArrayList<String>();
final ArrayAdapter<R.String> aa;
If so, try changing them to use String instead. It should look more like this:
Code:
final ArrayList<String> todoItems  = new ArrayList<String>();
final ArrayAdapter<String> aa;
Let me know if that helps, otherwise it might be worth posting everything in your onCreate method and I'll see if I can replicate the problem.
__________________
Reto Meier

Author, "Professional Android 4 Application Development", Wrox, ©2012, 2010, 2008
@retomeier
Reply With Quote
  #3 (permalink)  
Old January 22nd, 2010, 06:43 AM
Registered User
 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Reto View Post
From the error message it looks like the ArrayList "todoItems" has been declared using the type R.String instead of String.

Just above the code you pasted there are two lines that initialize the generic ArrayList and ArrayAdapter classes, it seems like they might be specifying the type as R.String rather than String. If that's the case you're code might look like this:
Code:
final ArrayList<R.String> todoItems  = new ArrayList<String>();
final ArrayAdapter<R.String> aa;
If so, try changing them to use String instead. It should look more like this:
Code:
final ArrayList<String> todoItems  = new ArrayList<String>();
final ArrayAdapter<String> aa;
Let me know if that helps, otherwise it might be worth posting everything in your onCreate method and I'll see if I can replicate the problem.
I had this problem. It was because I'd put the word String in lowercase on the declarations, changed and it worked. Coming from a VB.NET and Delphi background it's something I must remember....CASE SENSITIVE.....Doooohhh..
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
SRS2005 List report having page break issues LenexaKS Reporting Services 0 August 29th, 2008 11:48 AM
HELP: CSS COLLAPSIBLE LIST ISSUES phpuser2000 CSS Cascading Style Sheets 0 December 13th, 2007 04:22 PM
Transparency Key issues... Xc0d C# 2005 3 November 27th, 2007 04:13 PM
TODO Samikaraeen Pro VB 6 1 August 3rd, 2004 12:24 PM
MultiSelect List Box and Other issues... snoopy92211 Access VBA 0 July 14th, 2004 01:27 PM



All times are GMT -4. The time now is 07:43 PM.


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