• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not letting me create and add user defined object to ArrayList

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been hacking away at me check list that allows me to add strings via dialog box. The strings are then added to an ArrayList<Item> which I have a separate class that defines that object. As far as I can tell I have the syntax correct but it tells me "The constructor ClickData.Item(String, boolean) is undefined"
The problem is in the addItem() method "aiItems.add(new Item(sItem, true));" Any thoughts as to how I can get this to work so that I can add it to the ArrayList<Item>? Thanks in advance.

ListActivetyDemo.java


Item.java
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the message mention "ClickData.Item" or "ClipData.Item"? You imported the latter, so perhaps you retyped the error message with errors instead of just copying and pasting it?

In any case the Item class whose code you posted isn't either of those. If you want to use the Item class that you posted, then you shouldn't be importing a different Item class (i.e. android.content.ClipData.Item). In fact since the Item class that you posted is in the same package as your ListActivityDemo class, you shouldn't have to import any Item class at all.
 
Tom Mordon
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It says ClipData.Item(String, boolean), pasted below is the error I copied. Yeah its weird will try retyping the method to see if that does anything.

"The constructor ClipData.Item(String, boolean) is undefined"
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So this "Item" class you want to use... is it the Item class whose code you posted, or is it that ClipData.Item class?
 
Tom Mordon
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The thing is I have no idea what ClipData.Item is, I'm just trying to use Item.java since it defines the Item object I created. So yes I'm trying to use the Item.java which defines my Item object.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tom Mordon wrote:The thing is I have no idea what ClipData.Item is, I'm just trying to use Item.java since it defines the Item object I created. So yes I'm trying to use the Item.java which defines my Item object.



Then importing ClipData.Item wasn't the right thing to do. I expect you did that at an earlier stage when your IDE told you it couldn't find an Item class and gave you a list of things which might be suitable, and you chose one at random from the list. Or something like that. Anyway you don't want to use ClipData.Item so don't import it.
 
Tom Mordon
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, that makes sense now. Need to pay attention to imports.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic