Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old February 4th, 2012, 11:12 AM   #1 (permalink)
New Member
 
Join Date: Feb 2012
Posts: 1
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default Twitter feed on LinearLayout and ListView

Hi, i've got a code to get the timeline from twitter of a user, but i want to put the result on a ListView but no on a ListActivity, i wanna put it in a Activity, i mean i've got two linearlayouts and i want to create a listview like a child and inside the twitter feed, and change the look, putting the text black, but i don't know how, here is the code to fetch the timeline:

To get the timeline works perfectly, the problem is how to show in a listview. Thanks.

Code:
public ArrayList<String> fetchTwitterTimeline(String username, int count) {
        ArrayList<String> listItems = new ArrayList<String>();
        
        String host = "api.twitter.com";
        username="@marca";
        count=20;
        String twitterURL = "LINK TO TWITTER API AND USER";
        try {
            HttpClient client = new DefaultHttpClient();
            BasicHttpContext localContext = new BasicHttpContext();
            HttpHost targetHost = new HttpHost(host, 80, "http");
            HttpGet httpget = new HttpGet(twitterURL);
            httpget.setHeader("Content-Type", "application/json");
            HttpResponse response = client.execute(targetHost, httpget, localContext);
            HttpEntity entity = response.getEntity();
            Object content = EntityUtils.toString(entity);
            Log.d(paquete, "OK: " + content.toString());
               
            JSONArray ja = new JSONArray(content.toString());
                  
            for(int i = 0; i < ja.length(); i++){
               JSONObject jo = ja.getJSONObject(i);
               listItems.add(jo.getString("text"));
              }
        } catch(Exception e) {
            e.printStackTrace();
        }
    return listItems;
}

kurdt91 is offline  
Reply With Quote
Sponsors
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 12:13 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo