Search in sources :

Example 36 with SimpleCursorAdapter

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

Example 37 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 38 with SimpleCursorAdapter

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

Example 39 with SimpleCursorAdapter

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

Example 40 with SimpleCursorAdapter

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

Aggregations

SimpleCursorAdapter (android.widget.SimpleCursorAdapter)61 Cursor (android.database.Cursor)38 ListAdapter (android.widget.ListAdapter)16 ListView (android.widget.ListView)14 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)5 TextView (android.widget.TextView)3 Test (org.junit.Test)3 Intent (android.content.Intent)2 Uri (android.net.Uri)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