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.
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;
}