ArrayAdapter contains an object based on a value

不问归期 提交于 2019-12-12 03:08:19

问题


I have a ListView and ListView adapter. I am adding objects to the adapter but I only want to add one row with an object that contains a certain String. This is my code but it does not work:

public static List<FriendsVideoLVModel> list = new ArrayList<FriendsVideoLVModel>();

    @Override
public void add(FriendsVideoLVModel obj) {
    super.add(obj);

   for (int i=0; i <list.size(); i++) {
       if (!obj.eventTitle.equals(list.get(i).eventTitle)) {
           list.add(obj);
           notifyDataSetChanged();
       }
   }
}

Please help. The logic looks fine to me but it just does not work. Nothing is in fact added.

来源:https://stackoverflow.com/questions/28825038/arrayadapter-contains-an-object-based-on-a-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!