package com.haya.tabulae.activities;

import java.util.ArrayList;

import com.activeandroid.query.Select;
import com.haya.tabulae.R;
import com.haya.tabulae.adapters.ItemAdapter;
import com.haya.tabulae.models.Item;
import com.haya.tabulae.utils.Utils;

import android.app.ListActivity;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class ItemsActivity extends ListActivity {

	private ItemAdapter adapterList;
	
	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_items);
		getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
		Utils.setBackground(this, android.R.color.holo_purple);
		
		populateList();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		getMenuInflater().inflate(R.menu.items, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
	
	
	private void populateList() {
		
		ArrayList<Item> items = new Select().from(Item.class).execute();		
		adapterList = new ItemAdapter(this, R.layout.item, R.id.ItemTitle, items);
		getListView().setAdapter(adapterList);
	}
	
}

@@ -862,16 +862,115 @@
 rple);%0D%0A
+%09%09getActionBar().setHomeButtonEnabled(true);%0D%0A%09%09getActionBar().setLogo(R.drawable.ic_arrow_back);%0D%0A
 %09%09%0D%0A%09%09po
@@ -1232,17 +1232,33 @@
 %0D%0A%09%09
-if (id ==
+%0D%0A%09%09switch(id) %7B%0D%0A%09%09%09case
  R.i
@@ -1278,35 +1278,89 @@
 ings
-) %7B
+:
 %0D%0A%09%09%09
-return true
+%09%0D%0A%09%09%09%09break;%0D%0A%09%09%09case android.R.id.home:%0D%0A%09%09%09%09finish();%0D%0A%09%09%09%09break
 ;%0D%0A%09%09%7D%0D%0A
 %09%09re
@@ -1355,16 +1355,20 @@
 ;%0D%0A%09%09%7D%0D%0A
+%09%09%0D%0A
 %09%09return

Create activity #35 (III) Back button added