/
ScheduleActivity.java
42 lines (33 loc) · 1.18 KB
/
ScheduleActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.lsiegert;
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ListView;
public class ScheduleActivity extends ListActivity {
private DatabaseHelper dbHelper = null;
private ListView listView = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
listView = getListView();
listView.setItemsCanFocus(true);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
if (dbHelper == null) {
dbHelper = new DatabaseHelper(this);
}
dbHelper.openDatabase();
SeparatedListAdapter adapter = new SeparatedListAdapter(this);
Cursor seasons = dbHelper.getAllSeasons();
startManagingCursor(seasons);
seasons.moveToFirst();
while (!seasons.isAfterLast()) {
String season = seasons.getString(0);
Cursor games = dbHelper.getGamesBySeason(season);
startManagingCursor(games);
ScheduleAdapter scheduleAdapter = new ScheduleAdapter(this, R.layout.schedule_row, games, null, null, dbHelper);
adapter.addSection(season, scheduleAdapter);
seasons.moveToNext();
}
setListAdapter(adapter);
}
}