use of android.widget.SimpleCursorAdapter in project K6nele by Kaljurand.
the class ServerListActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] columns = new String[] { Server.Columns._ID, Server.Columns.URL };
int[] to = new int[] { R.id.itemServerId, R.id.itemServerUrl };
Cursor managedCursor = managedQuery(CONTENT_URI, columns, null, null, Server.Columns.URL + " ASC");
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, R.layout.list_item_server, managedCursor, columns, to);
ListView lv = getListView();
setEmptyView(getString(R.string.emptylistServers));
lv.setAdapter(mAdapter);
registerForContextMenu(lv);
setClickToFinish(CONTENT_URI, Server.Columns._ID);
}
use of android.widget.SimpleCursorAdapter in project android-nfc-paycardreader by rayyan.
the class TransactionsActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.transactions);
Intent intent = this.getIntent();
MatrixCursor cursor = new MatrixCursor(new String[] { "_id", "action", "amount", "hknr", "date", "time" });
for (Integer i = 1; i <= 15; i++) {
byte[] recv = intent.getByteArrayExtra(String.format("blog_%d", i));
if (recv == null)
continue;
Integer len = recv.length;
if (len > 33 && recv[len - 2] == (byte) 0x90 && recv[len - 1] == 0) {
String action = SharedUtils.parseLogState(recv[0]);
String amount = SharedUtils.formatBCDAmount(Arrays.copyOfRange(recv, 17, 20));
String hknr = SharedUtils.Byte2Hex(Arrays.copyOfRange(recv, 3, 13), "");
if (hknr.equals("00000000000000000000"))
continue;
String date = String.format("%02x.%02x.%02x%02x", recv[31], recv[30], recv[28], recv[29]);
String time = String.format("%02x:%02x", recv[32], recv[33]);
cursor.addRow(new String[] { i.toString(), action, amount, hknr, date, time });
}
}
ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.transaction_listitem, cursor, new String[] { "action", "amount", "hknr", "date", "time" }, new int[] { R.id.listitem_action, R.id.listitem_amount, R.id.listitem_hknr, R.id.listitem_date, R.id.listitem_time });
setListAdapter(adapter);
}
use of android.widget.SimpleCursorAdapter in project AndroidSDK-RecipeBook by gabu.
the class Recipe085 method onResume.
@Override
public void onResume() {
super.onResume();
MySQLiteOpenHelper helper = new MySQLiteOpenHelper(getApplicationContext());
mDB = helper.getReadableDatabase();
String where = "age >= ?";
String[] args = { "5" };
Cursor cursor;
cursor = mDB.query("people", null, where, args, null, null, null);
// カーソルのライフサイクル管理を
// アクティビティに任せます。
startManagingCursor(cursor);
// from: カラム名の配列
String[] from = { "name", "age" };
// to: fromに対応するビューのIDの配列
int[] to = { R.id.name_in_list, R.id.age_in_list };
SimpleCursorAdapter adapter;
adapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.row, cursor, from, to);
ListView listView = (ListView) findViewById(R.id.list_view);
listView.setAdapter(adapter);
}
use of android.widget.SimpleCursorAdapter in project musicbrainz-android by jdamcd.
the class SuggestionHelper method getAdapter.
public SimpleCursorAdapter getAdapter() {
SimpleCursorAdapter adapter = new SimpleCursorAdapter(context, R.layout.dropdown_item, null, FROM, TO);
adapter.setCursorToStringConverter(new SuggestionCursorToString());
adapter.setFilterQueryProvider(new SuggestionFilterQuery());
return adapter;
}
use of android.widget.SimpleCursorAdapter in project coursera-android by aporter.
the class DatabaseExampleActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create a new DatabaseHelper
mDbHelper = new DatabaseOpenHelper(this);
// start with an empty database
clearAll();
// Insert records
insertArtists();
// Create a cursor
Cursor c = readArtists();
mAdapter = new SimpleCursorAdapter(this, R.layout.list_layout, c, DatabaseOpenHelper.columns, new int[] { R.id._id, R.id.name }, 0);
setListAdapter(mAdapter);
Button fixButton = (Button) findViewById(R.id.fix_button);
fixButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// execute database operations
fix();
// Redisplay data
mAdapter.getCursor().requery();
mAdapter.notifyDataSetChanged();
}
});
}
Aggregations