Am I creating my custom ArrayAdapter correctly?

后端 未结 1 1338
渐次进展
渐次进展 2020-12-18 16:04

My ListView populates correctly, but for some reason adding and removing is quirky and does not work properly! Am I doing something wrong?

Set things up in OnCreate(

相关标签:
1条回答
  • 2020-12-18 16:36

    The code seems to be alright. Can you try using this in your remove?:

    if("Remove".equals(item.getTitle())) {
       //....
    }
    

    Edit:

    I just noticed you are de-serializing "Quote" objects by calling deserializeQuotes(). Have you overridden the boolean equals(Object) method of Quote object? When you de-serialize, the object created are not the "same", i.e. they are new objects altogether and if you haven't overridden the equals method:

    quotesAdapter.remove(quotes.get(info.position));
    

    will fail because it won't find any Quote object to remove in the list.

    Can you check that?

    0 讨论(0)
提交回复
热议问题