简体   繁体   中英

Android - Get Twitter timeline using fabric

I'm working on an Android application, where I have to show an specific timeline. Well I have added fabric.io and I also created a twitter app(I mean I got the keys). So I really don't know how can I get the twitts on my class to display them on my listview. let see the code below:

TwitterAuthConfig authConf =
                new TwitterAuthConfig(this.getResources().getString(R.string.consumerKey),
                        this.getResources().getString(R.string.consumerSecret));
        Fabric.with(this, new Twitter(authConfig));

final UserTimeline userTimeline = new UserTimeline.Builder()
                .screenName("TwitterUser")
                .build();

So, how can I grab the tweets from the userTimeline . Maybe I'm confuse and I'm implementing it wrong.

The UserTimeline can be passed to the TweetTimelineListAdapter . The TweetTimelineListAdapter can be used on any ListView.

From the docs: http://docs.fabric.io/android/twitter/show-timelines.html#listactivity

import com.twitter.sdk.android.tweetui.TweetTimelineListAdapter;
import com.twitter.sdk.android.tweetui.UserTimeline;

public class TimelineActivity extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.timeline);

        final UserTimeline userTimeline = new UserTimeline.Builder()
            .screenName("fabric")
            .build();
        final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter(this, userTimeline);
        setListAdapter(adapter);
    }
}

You can use http://docs.fabric.io/android/twitter/show-timelines.html#listactivity fabric documentation. All of you need is found fabric documentation. But if you want use your own adapter (custom adapter) you can use this github-gist-link. https://gist.github.com/sabadow/a7dd2575325b676a113e

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM