Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error:(56, 28) error: cannot find symbol method clear()

 
John Joe
Ranch Hand
Posts: 55
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day guys. I have a listView, and AllAdapter adapter where the AllAdapter is extending to BaseAdapter

Why I get error on line adapter.clear()?

Error



Code

  
 
Rob Spoor
Sheriff
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BaseAdapter doesn't have a clear() method. That means that you will need to declare adapter as AllAdapter and not as BaseAdapter. Can you show us how you declared adapter?
 
John Joe
Ranch Hand
Posts: 55
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:BaseAdapter doesn't have a clear() method. That means that you will need to declare adapter as AllAdapter and not as BaseAdapter. Can you show us how you declared adapter?


This is how I declare adapter



And code after setContentView



And finally AllAdapter Class

 
Norm Radder
Bartender
Posts: 1526
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cannot find symbol method clear()

Where do you think the method clear() is defined? What class in what package?
 
John Joe
Ranch Hand
Posts: 55
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:
cannot find symbol method clear()

Where do you think the method clear() is defined? What class in what package?


I post part of my code here.

 
Norm Radder
Bartender
Posts: 1526
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't answer my question:
Where do you think the clear() method is defined?  What class is it in?
If the compiler can not find a definition for a method it will flag that statement as an error.
 
John Joe
Ranch Hand
Posts: 55
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:That doesn't answer my question:
Where do you think the clear() method is defined?  What class is it in?
If the compiler can not find a definition for a method it will flag that statement as an error.


Do you mean that I need to create a clear method in AllAdapter class ? I would like to clear all the listview item first before they added into listview.
 
Norm Radder
Bartender
Posts: 1526
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean that I need to create a clear method in AllAdapter class ?

You can not call a method that does not exist.  If you want the AllAdapter class to have a clear method, you will have to write it.

Copied to Android section.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic