package com.brogrammers.agora;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AnswerAdapter extends BaseAdapter {
	
	private Question question;
	private LayoutInflater inflater;
	

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return question.countAnswers();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return question.getAnswers().get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return question.getAnswers().get(position).getID();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if(convertView == null){
			
			//inflate each listview item with "answer_object"
			convertView = inflater.inflate(R.layout.answer_object, parent, false);
			Answer answer = (Answer)getItem(position);
			
			//set text on each TextView
			((TextView)convertView.findViewById(R.id.aBody)).setText(answer.getBody());
			((TextView)convertView.findViewById(R.id.aScore)).setText(Integer.toString(answer.getRating()));
			((TextView)convertView.findViewById(R.id.aAuthourDate)).setText(answer.getDate().toString());
			
		}
		return null;
	}

}

@@ -27,16 +27,49 @@
 ora;%0D%0A%0D%0A
+import android.content.Context;%0D%0A
 import a
@@ -280,16 +280,187 @@
 r %7B%0D%0A%09%0D%0A
+%09AnswerAdapter(Question q)%7B%0D%0A%09%09this.question = q;%0D%0A%09%09this.inflater = (LayoutInflater)Agora.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);%0D%0A%09%09%0D%0A%09%09%0D%0A%09%7D%0D%0A%09%0D%0A
 %09private

Add constructor to AnswerAdapter