PostListAdapter.java :  » UnTagged » easywordpress » android » easyp » Android Open Source

Android Open Source » UnTagged » easywordpress 
easywordpress » android » easyp » PostListAdapter.java
package android.easyp;

import android.content.Context;
import android.easyp.model.ITeaserPost;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class PostListAdapter extends ArrayAdapter<ITeaserPost> {

  public PostListAdapter(Context context, int textViewResourceId,
      ITeaserPost[] objects) {
    super(context, textViewResourceId, objects);
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
      LayoutInflater vi = (LayoutInflater) this.getContext()
          .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      v = vi.inflate(R.layout.post_item, null);
    }
    ITeaserPost o = getItem(position);
    if (o != null) {
      TextView ti = (TextView) v.findViewById(R.id.title_item);
      TextView ci = (TextView) v.findViewById(R.id.content_item);
      if (ti != null) {
        ti.setText(o.getPostTitle());
      }
      if (ci != null) {
        ci.setText(o.getDate());
      }
    }
    return v;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.