Created
September 22, 2009 03:32
-
-
Save konklone/190789 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected class TweetAdapter extends BaseAdapter { | |
private Activity context; | |
private Status[] tweets; | |
LayoutInflater inflater; | |
public TweetAdapter(Activity c, Status[] tw) { | |
context = c; | |
tweets = tw; | |
inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | |
} | |
public int getCount() { | |
return tweets.length; | |
} | |
public Object getItem(int position) { | |
return tweets[position]; | |
} | |
public long getItemId(int position) { | |
Status tweet = (Status) getItem(position); | |
return tweet.getId(); | |
} | |
public View getView(int position, View convertView, ViewGroup parent) { | |
LinearLayout view; | |
if (convertView == null) { | |
view = (LinearLayout) inflater.inflate(R.layout.legislator_tweet, null); | |
} else { | |
view = (LinearLayout) convertView; | |
} | |
Status tweet = (Status) getItem(position); | |
TextView text = (TextView) view.findViewById(R.id.tweet_text); | |
text.setText(tweet.getText()); | |
TextView when = (TextView) view.findViewById(R.id.tweet_when); | |
when.setText(tweet.getCreatedAt().toGMTString()); | |
return view; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment