Copyright (c) 2012, Edinburgh Council
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are ...
If you think the Android project City-Outdoors-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package uk.co.jarofgreen.cityoutdoors.UI;
//fromwww.java2s.comimport uk.co.jarofgreen.cityoutdoors.OurApplication;
import uk.co.jarofgreen.cityoutdoors.Storage;
import uk.co.jarofgreen.cityoutdoors.R;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.os.Bundle;
import android.provider.BaseColumns;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
/**
*
* @author James Baster <james@jarofgreen.co.uk>
* @copyright City of Edinburgh Council & James Baster
* @license Open Source under the 3-clause BSD License
* @url https://github.com/City-Outdoors/City-Outdoors-Android
*/publicclass CollectionsActivity extends BaseListActivity {
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ListView listView = getListView();
// view
LayoutInflater layoutInflater = getLayoutInflater();
View header = layoutInflater.inflate(R.layout.title_bar,null);
listView.addHeaderView(header, new Object(), false);
TitleBar.populate(this);
listView.setBackgroundResource(R.drawable.background);
listView.setCacheColorHint(Color.WHITE);
// data
Storage storage = ((OurApplication)getApplication()).getStorage();
SQLiteDatabase db = storage.getReadableDatabase();
final String fields[] = { BaseColumns._ID, "title", "description"};
Cursor mCursor = db.query("collection", fields, "", null, null, null, null);
startManagingCursor(mCursor);
ListAdapter adapter = new SimpleCursorAdapter(
this,
R.layout.collection_row,
mCursor,
new String[] {"title","description"},
newint[] {R.id.title, R.id.description});
setListAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
publicvoid onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(CollectionsActivity.this, CollectionActivity.class);
intent.putExtra("collectionID",(int)id);
startActivity(intent);
}
});
}
}