自定义ListArray的最后一个索引,它等于特定值

问题描述 投票:0回答:1

我有一个包含聊天消息(List<Chat>)的列表。

列表包含message, senderID and sentTime。它看起来如下:

enter image description here

我正在尝试找到消息等于"Do you confirm that you received..."的索引

我尝试使用chats.indexOf("Do you confirm that you received...")

但是,我一直收到-1

我做错了什么?具体来说,如果在该聊天中有多条消息等于"Do you confirm that you received...",我想找到最后一个索引。

谢谢

android arraylist indexof
1个回答
0
投票

[chats.indexOf("Do you confirm that you received...")不起作用,因为您要在chats.message中查找并将其与所需值进行比较。

© www.soinside.com 2019 - 2024. All rights reserved.