package in.co.sdslabs.cognizance;

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

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class EventCategoryFragment extends ListFragment {

	//private ListView mEventList;
	private List<HashMap<String, String>> eventList;
	private SimpleAdapter mAdapter;

	private String EVENTNAME = "eventname";
	private String EVENTVENUE = "venue";

	public EventCategoryFragment() {
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Retrieving the currently selected item number
		 int position = getArguments().getInt("position");
		//
		// // List of rivers
		 String[] countries =
		 getResources().getStringArray(R.array.eventCategories);
		

		// Creating view correspoding to the fragment
		View v = inflater.inflate(R.layout.eventcategoryfragment_layout,
				container, false);

		eventList = new ArrayList<HashMap<String, String>>();

		TextView tv = (TextView) v.findViewById(R.id.tv_categoryDescription);
		tv.setText(countries[position]);
	//	mEventList = (ListView) v.findViewById(R.id.eventCategory_list);

		for (int i = 0; i < 100; i++) {
			HashMap<String, String> hm = new HashMap<String, String>();
			hm.put(EVENTNAME, "" + i);
			// hm.put(IMAGE, Integer.toString(mImages[i]));
			eventList.add(hm);
		}

		String[] from = { EVENTNAME };

		int[] to = { R.id.tv_event_name };

		// Instantiating an adapter to store each items
		// R.layout.drawer_layout defines the layout of each item
		mAdapter = new SimpleAdapter(getActivity().getBaseContext(), eventList,
				R.layout.eventcategory_list_item, from, to);

		setListAdapter(mAdapter);

		return v;
	}

}
@@ -28,16 +28,44 @@
 zance;%0A%0A
+import java.io.IOException;%0A
 import j
@@ -134,16 +134,54 @@
 .List;%0A%0A
+import android.database.SQLException;%0A
 import a
@@ -375,40 +375,8 @@
 ter;
-%0Aimport android.widget.TextView;
 %0A%0Apu
@@ -435,16 +435,17 @@
 t %7B%0A%0A%09//
+ 
 private 
@@ -624,12 +624,58 @@
  = %22
-venu
+eventvenue%22;%0A%09private String EVENTTIME = %22eventtim
 e%22;%0A
@@ -920,17 +920,16 @@
 umber%0A%09%09
- 
 int posi
@@ -974,39 +974,11 @@
 %22);%0A
+%0A
 %09%09
-//%0A%09%09// // List of rivers%0A%09%09 
 Stri
@@ -987,21 +987,19 @@
 %5B%5D c
-ount
+atego
 ries =
-%0A%09%09
  get
@@ -1025,16 +1025,21 @@
 ngArray(
+%0A%09%09%09%09
 R.array.
@@ -1055,19 +1055,16 @@
 gories);
-%0A%09%09
 %0A%0A%09%09// C
@@ -1255,16 +1255,353 @@
 %3E();%0A%0A%09%09
+// Initialising DBhelper class%0A%0A%09%09DatabaseHelper myDbHelper = new DatabaseHelper(getActivity()%0A%09%09%09%09.getBaseContext());%0A%09%09try %7B%0A%09%09%09myDbHelper.createDataBase();%0A%09%09%7D catch (IOException ioe) %7B%0A%09%09%09throw new Error(%22Unable to create database%22);%0A%09%09%7D%0A%0A%09%09try %7B%0A%09%09%09myDbHelper.openDataBase();%0A%09%09%7D catch (SQLException sqle) %7B%0A%09%09%09throw sqle;%0A%09%09%7D%0A%09%09// 
 TextView
@@ -1664,16 +1664,19 @@
 ion);%0A%09%09
+// 
 tv.setTe
@@ -1683,12 +1683,13 @@
 xt(c
-ount
+atego
 ries
@@ -1705,12 +1705,13 @@
 %5D);%0A
+%09
 %09//
-%09
+ 
 mEve
@@ -1772,16 +1772,150 @@
 list);%0A%0A
+%09%09/** Create function in DBhelper to return these three values **/%0A%09%09// String Data = DBhelper.getReducedEvent(categories%5Bposition%5D);%0A
 %09%09for (i
@@ -1932,10 +1932,9 @@
 i %3C 
-10
+2
 0; i
@@ -2029,12 +2029,61 @@
 , %22%22
- + i
+);%0A%09%09%09hm.put(EVENTVENUE, %22%22);%0A%09%09%09hm.put(EVENTTIME, %22%22
 );%0A%09
@@ -2221,15 +2221,41 @@
 tv_e
-vent_na
+Name, R.id.tv_eVenue, R.id.tv_eTi
 me %7D

Update category fragment class and initialise dbHelper