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){
			convertView = inflater.inflate(R.layout.answer_object, parent, false);
			Answer answer = (Answer)getItem(position);
			((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;
	}

}

@@ -879,16 +879,75 @@
 null)%7B%0D%0A
+%09%09%09%0D%0A%09%09%09//inflate each listview item with %22answer_object%22%0D%0A
 %09%09%09conve
@@ -1056,24 +1056,61 @@
 position);%0D%0A
+%09%09%09%0D%0A%09%09%09//set text on each TextView%0D%0A
 %09%09%09((TextVie

add Comments to AnswerAdapter