Using TweetTimelineListAdapter method to get the tweets

594 views Asked by At

by making use of TweetTimeListAdapter im able to show the tweets in my application. How do I retrieve the specific details like the message and the timestamp itself?

    final UserTimeline userTimeline = new UserTimeline.Builder()
            .screenName("<Your_ScreenName>")
            .build();
    final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter(this, userTimeline);

I tried using the adapter class but to no avail. Thanks!

EDIT 1: Adapter.getCount prints out 0 when there is 2 tweets loaded into the listview.

EDIT 2 Adpater.getTweets is not a valid function.

enter image description here

1

There are 1 answers

8
reidzeibel On

From what I read on the documentation, you would need to get the List of Tweets that you get from the adapter. I think you should be able to get the Tweet list from the UserTimeline object or Adapter.

You would want to pull a List<Tweet>, then iterate the Tweet for message & timestamp.

Maybe somewhere along this line : (note that I haven't used twitter-fabric at all, so you need to find the correct implementation)

EDIT

After reading the documentation, you can do this to get Tweets :

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;
}

Here's the Tweet Model documentation, you should be able to get anything there. Good luck