Trying to integrate a timeline to my app


#1

I’m trying to integrate Twitter into my application, however setListAdapter is unresolved, and I’m not sure how to fix it.

public class Main2Activity extends AppCompatActivity {
Button button3;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2);
    button3 = (Button) findViewById(R.id.button3);
    button3.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View arg0) {
            Intent myIntent = new Intent(Main2Activity.this,
                    MainActivity.class);
            startActivity(myIntent);
        }
    });
    final UserTimeline userTimeline = new UserTimeline.Builder()
            .screenName("fabric")
            .build();
    final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(this)
            .setTimeline(userTimeline)
            .build();
    setListAdapter(adapter);
}

#2

Hey @KonnorxG,

Can you share the full error you’re seeing? Based on the code you’ve shared, I think you would need to create a ListView and then do:

myListView.setListAdapter(adapter);

More information on List Views can be found here: https://developer.android.com/reference/android/widget/ListView.html


#3

Okay, I added that
Here’s the activity

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

}
And the .xml

and the error
Error:(41, 9) error: cannot find symbol method setListAdapter(TweetTimelineListAdapter)
Error:(33, 19) error: int cannot be dereferenced
Error:(33, 35) error: cannot find symbol variable adapter

Thank you for your help


#4

Sorry, I’m new to this but, i set it to extend ListActivity instead of AppCompatActivity, and it’s working now. Thank you for your assistance though!


#5