Customize a TweetTimeline



Hi all!

I need to customize a TweetTimeline by adding an identification number at the left part of each tweet, something like the following image:

Before creating my own Adapter and trying to read each Tweet from List<Tweet>, I want to know if I can edit somehow the TweetTimelineListAdapter in order to change the layout of each element. Is this possible?

The code that I am using for obtaining the List<Tweet> object is the following:

TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient();
        StatusesService statusesService = twitterApiClient.getStatusesService();

        Call<List<Tweet>> call = statusesService.homeTimeline(200,null,null,false,false,true,true);
        call.enqueue(new Callback<List<Tweet>>() {
            public void success(Result<List<Tweet>> result) {
                ListView listView = (ListView) findViewById(;
                final FixedTweetTimeline timeline = new FixedTweetTimeline.Builder()
                final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(HomeTimelineActivity.this)

            public void failure(TwitterException exception) {


You could override TweetTimelineListAdapter#getView(int position, View convertView, ViewGroup parent) to return your custom view.

public View getView(int position, View convertView, ViewGroup parent) {
    View tweetView = super.getView(position, convertView, parent);
   // Add view to another layout and return the view.


Thanks for the answer!

But how can I access to each element layout from the View in order to edit it?


We don’t provide access to the internal of the Tweet view. But you should be able to add numbers without access to internal views.


This isn’t working for me. I wanted to wrap each tweet in a CardLayout.

First I extended CompactTweetView as MyCompactTweetView to override getLayout and return a custom layout id. I copied the original compact tweet layout and placed it inside a card view.

Then I extended TweetTimelineListAdapter as MyTweetTimelineListAdapter and override getView to call MyCompactTweetView.

However, the build() function of the extended MyTweetTimelineListAdapter.Builder() only returns a TweetTimelineListAdapter object which forces the code to run getView from TweetTimelineListAdapter. So my overridden getView is never touched.


Try using the constructor of your MyTweetTimelineListAdapter instead of the builder pattern,
e.g., MyTweetTimelineListAdapter adapter = new MyTweetTimelineListAdapter(getActivity(), timeline);