Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Events.java
Package: Android-code.zip [view]
Upload User: xmjingguan
Upload Date: 2009-07-06
Package Size: 2054k
Code Size: 2k
Category:
android
Development Platform:
Java
- /***
- * Excerpted from "Hello, Android!",
- * published by The Pragmatic Bookshelf.
- * Copyrights apply to this code. It may not be used to create training material,
- * courses, books, articles, and the like. Contact us if you are in doubt.
- * We make no guarantees that this code is fit for any purpose.
- * Visit http://www.pragmaticprogrammer.com/titles/eband for more book information.
- ***/
- package org.example.events;
- import static android.provider.BaseColumns._ID;
- import static org.example.events.Constants.CONTENT_URI;
- import static org.example.events.Constants.TIME;
- import static org.example.events.Constants.TITLE;
- import android.app.ListActivity;
- import android.content.ContentValues;
- import android.database.Cursor;
- import android.os.Bundle;
- import android.widget.SimpleCursorAdapter;
- public class Events extends ListActivity {
- private static String[] FROM = { _ID, TIME, TITLE, };
- private static int[] TO = { R.id.rowid, R.id.time, R.id.title, };
- private static String ORDER_BY = TIME + " DESC";
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- addEvent("Hello, Android!");
- Cursor cursor = getEvents();
- showEvents(cursor);
- }
- private void addEvent(String string) {
- // Insert a new record into the Events data source.
- // You would do something similar for delete and update.
- ContentValues values = new ContentValues();
- values.put(TIME, System.currentTimeMillis());
- values.put(TITLE, string);
- getContentResolver().insert(CONTENT_URI, values);
- }
- private Cursor getEvents() {
- // Perform a managed query. The Activity will handle closing
- // and re-querying the cursor when needed.
- return managedQuery(CONTENT_URI, FROM, null, null, ORDER_BY);
- }
- private void showEvents(Cursor cursor) {
- // Set up data binding
- SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
- R.layout.item, cursor, FROM, TO);
- setListAdapter(adapter);
- }
- }