package ca.ualberta.cs.cmput301f14t14.questionapp;

import java.util.ArrayList;
import java.util.List;

import ca.ualberta.cs.cmput301f14t14.questionapp.model.Comment;
import ca.ualberta.cs.cmput301f14t14.questionapp.view.CommentListAdapter;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.TabHost;

public class QuestionActivity extends Activity {
	static final String TAB_ANSWERS = "answer";
	static final String TAB_COMMENTS = "comment";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_question);

		TabHost tabs = (TabHost) findViewById(android.R.id.tabhost);
		tabs.setup();

		TabHost.TabSpec aTab = tabs.newTabSpec(TAB_ANSWERS);
		aTab.setContent(R.id.answerSummaryList);
		aTab.setIndicator(getString(R.string.tab_answers));
		tabs.addTab(aTab);

		TabHost.TabSpec cTab = tabs.newTabSpec(TAB_COMMENTS);
		cTab.setContent(R.id.commentList);
		cTab.setIndicator(getString(R.string.tab_comments));
		tabs.addTab(cTab);

		List<Comment> cl = new ArrayList<Comment>();
		// Populate list with dummy data for now...
		cl.add(new Comment("This is a demo comment which will exceed the screen width.", "Boris"));
		cl.add(new Comment("Shorter comment.", "Natasha"));

		CommentListAdapter cla = new CommentListAdapter(this, R.layout.list_comment, cl);
		ListView commentView = (ListView) findViewById(R.id.commentList);
		commentView.setAdapter(cla);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.question, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}

@@ -152,23 +152,159 @@
 p.model.
-Comment
+Answer;%0Aimport ca.ualberta.cs.cmput301f14t14.questionapp.model.Comment;%0Aimport ca.ualberta.cs.cmput301f14t14.questionapp.view.AnswerListAdapter
 ;%0Aimport
@@ -1262,16 +1262,178 @@
 cTab);%0A%0A
+%09%09List%3CAnswer%3E al = new ArrayList%3CAnswer%3E();%0A%09%09// Populate list with dummy data for now...%0A%09%09al.add(new Answer(%22The answer to your question is moot.%22, null));%0A%09%09%0A
 %09%09List%3CC
@@ -1666,16 +1666,203 @@
 ha%22));%0A%0A
+%09%09AnswerListAdapter ala = new AnswerListAdapter(this, R.layout.list_answer, al);%0A%09%09ListView answerView = (ListView) findViewById(R.id.answerSummaryList);%0A%09%09answerView.setAdapter(ala);%0A%09%09%0A
 %09%09Commen

Add AnswerList to QuestionActivity.