0

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

Gene
  • 2,178
  • 3
  • 30
  • 50

1 Answers1

0

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

reidzeibel
  • 1,622
  • 1
  • 19
  • 24
  • Hi bang, there is no getTweets method in userTimeline.getTweets(). – Gene Jun 16 '15 at 08:17
  • Can you find any similar method to get list of tweets? there should be one there. – reidzeibel Jun 16 '15 at 08:19
  • The only methods i found was for REST apis. – Gene Jun 16 '15 at 08:21
  • http://docs.fabric.io/javadocs/tweetui/1.2.0/com/twitter/sdk/android/tweetui/TweetViewAdapter.html TweetViewAdapter able to get tweets. how do i go around doing it? – Gene Jun 16 '15 at 08:27
  • anyway, just get the Tweet objects from the TweetViewAdapter, then you can get the message and timestamp :) – reidzeibel Jun 16 '15 at 08:30
  • TweetViewAdapter a1 = new TweetViewAdapter(this); System.out.println("DSD:" + a1.getCount()); It is printing nth as i think it did not make any connection to twitter svr. – Gene Jun 16 '15 at 08:43
  • Morning ried, see the above edit screenshot. It is not a valid method. Thks! – Gene Jun 17 '15 at 00:51
  • Update your fabric library, use the latest one, 1.4.0 or something if I recalled correctly – reidzeibel Jun 17 '15 at 02:03