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 platform_frameworks_base by android.
the class ListWithDisappearingItemBug method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Toast.makeText(this, "Make sure you rotate screen to see bug", Toast.LENGTH_LONG).show();
// Get a cursor with all people
Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
startManagingCursor(c);
ListAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view
R.layout.list_with_disappearing_item_bug_item, // Give the cursor to the list adatper
c, // Map the NAME column in the people database to...
new String[] { People.NAME }, // The "text1" view defined in the XML template
new int[] { R.id.text1 });
setListAdapter(adapter);
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(50);
set.addAnimation(animation);
animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(100);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
ListView listView = getListView();
listView.setLayoutAnimation(controller);
}
use of android.widget.SimpleCursorAdapter in project platform_frameworks_base by android.
the class ListManagedCursor method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get a cursor with all people
Cursor c = getContentResolver().query(Settings.System.CONTENT_URI, null, null, null, null);
startManagingCursor(c);
ListAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view
android.R.layout.simple_list_item_1, // Give the cursor to the list adatper
c, // Map the NAME column in the people database to...
new String[] { People.NAME }, // The "text1" view defined in the XML template
new int[] { android.R.id.text1 });
setListAdapter(adapter);
getListView().setOnItemClickListener(this);
}
use of android.widget.SimpleCursorAdapter in project coursera-android by aporter.
the class CustomContactProviderDemo method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContentResolver contentResolver = getContentResolver();
ContentValues values = new ContentValues();
// Insert first record
values.put(DataContract.DATA, "Record1");
Uri firstRecordUri = contentResolver.insert(DataContract.CONTENT_URI, values);
values.clear();
// Insert second record
values.put(DataContract.DATA, "Record2");
contentResolver.insert(DataContract.CONTENT_URI, values);
values.clear();
// Insert third record
values.put(DataContract.DATA, "Record3");
contentResolver.insert(DataContract.CONTENT_URI, values);
// Delete first record
contentResolver.delete(firstRecordUri, null, null);
// Create and set cursor and list adapter
Cursor c = contentResolver.query(DataContract.CONTENT_URI, null, null, null, null);
setListAdapter(new SimpleCursorAdapter(this, R.layout.list_layout, c, DataContract.ALL_COLUMNS, new int[] { R.id.idString, R.id.data }, 0));
}
use of android.widget.SimpleCursorAdapter in project coursera-android by aporter.
the class DisplayActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get Account information
// Must have a Google account set up on your device
mAccountList = AccountManager.get(this).getAccountsByType("com.google");
mType = mAccountList[0].type;
mName = mAccountList[0].name;
// Insert new contacts
insertAllNewContacts();
// Create and set empty list adapter
mAdapter = new SimpleCursorAdapter(this, R.layout.list_layout, null, columnsToDisplay, resourceIds, 0);
setListAdapter(mAdapter);
// Initialize a CursorLoader
getLoaderManager().initLoader(0, null, this);
}
Aggregations