Search in sources :

Example 21 with SimpleCursorAdapter

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);
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter) Intent(android.content.Intent) MatrixCursor(android.database.MatrixCursor) ListAdapter(android.widget.ListAdapter)

Example 22 with SimpleCursorAdapter

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);
}
Also used : ListView(android.widget.ListView) SimpleCursorAdapter(android.widget.SimpleCursorAdapter) LayoutAnimationController(android.view.animation.LayoutAnimationController) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) Cursor(android.database.Cursor) AnimationSet(android.view.animation.AnimationSet) ListAdapter(android.widget.ListAdapter) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 23 with SimpleCursorAdapter

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);
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter) Cursor(android.database.Cursor) ListAdapter(android.widget.ListAdapter)

Example 24 with SimpleCursorAdapter

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));
}
Also used : ContentValues(android.content.ContentValues) SimpleCursorAdapter(android.widget.SimpleCursorAdapter) Cursor(android.database.Cursor) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver)

Example 25 with SimpleCursorAdapter

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);
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter)

Aggregations

SimpleCursorAdapter (android.widget.SimpleCursorAdapter)60 Cursor (android.database.Cursor)37 ListAdapter (android.widget.ListAdapter)16 ListView (android.widget.ListView)13 AlphaAnimation (android.view.animation.AlphaAnimation)6 Animation (android.view.animation.Animation)6 AnimationSet (android.view.animation.AnimationSet)6 LayoutAnimationController (android.view.animation.LayoutAnimationController)6 TranslateAnimation (android.view.animation.TranslateAnimation)6 View (android.view.View)4 Test (org.junit.Test)3 Intent (android.content.Intent)2 Uri (android.net.Uri)2 TextView (android.widget.TextView)2 ContentResolver (android.content.ContentResolver)1 ContentValues (android.content.ContentValues)1 MatrixCursor (android.database.MatrixCursor)1 Drawable (android.graphics.drawable.Drawable)1 OnClickListener (android.view.View.OnClickListener)1 LayoutParams (android.view.ViewGroup.LayoutParams)1