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