通过使用TweetTimeListAdapter我能够在我的应用程序中显示推文。如何检索消息和时间戳本身等具体细节?
final UserTimeline userTimeline = new UserTimeline.Builder()
.screenName("<Your_ScreenName>")
.build();
final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter(this, userTimeline);
我尝试使用适配器类但无济于事。 谢谢!
编辑1: 当列表视图中加载了2条推文时,Adapter.getCount会输出0。
编辑2 Adpater.getTweets不是有效的功能。
答案 0 :(得分:0)
根据我在文档中阅读的内容,您需要获取从适配器获得的推文列表。我认为您应该能够从UserTimeline对象或适配器获取推文列表。
您需要提取List<Tweet>
,然后重复Tweet
以获取消息&amp;时间戳。
也许在这一行的某个地方:(注意我根本没有使用过twitter-fabric,所以你需要找到正确的实现)
编辑
阅读完文档后,您可以执行此操作以获取推文:
final UserTimeline userTimeline = new UserTimeline.Builder()
.screenName("<Your_ScreenName>")
.build();
final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter(this, userTimeline);
List<Tweets> tweetsList = adapter.getTweets(); //this will return tweets inside the adapter, if any
for (Tweets tweet : tweetsList) {
//Do Something with the tweet
//if you want to get the timestamp :
String timestamp = tweet.createdAt;
//if you want to get the message content :
String messageContent = tweet.text;
}
这是Tweet Model documentation,您应该可以在那里得到任何东西。祝你好运