Search in sources :

Example 56 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project android-sqlite-asset-helper by jgilfelt.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    db = new MyDatabase(this);
    // you would not typically call this on the main thread
    employees = db.getEmployees();
    ListAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, employees, new String[] { "FullName" }, new int[] { android.R.id.text1 });
    getListView().setAdapter(adapter);
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter) ListAdapter(android.widget.ListAdapter)

Example 57 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project AndroidDevelop by 7449.

the class MainActivity method init.

private void init() {
    writableDatabase = new DaoMaster.DevOpenHelper(this, "greendao", null).getWritableDatabase();
    DaoSession daoSession = new DaoMaster(writableDatabase).newSession();
    //得到Dao的对象
    userDao = daoSession.getUserDao();
    // 遍历表中所有的数据
    Cursor cursor = writableDatabase.query(userDao.getTablename(), userDao.getAllColumns(), null, null, null, null, null);
    String[] from = { UserDao.Properties.UserName.columnName, UserDao.Properties.UserSex.columnName };
    int[] id = { android.R.id.text1, android.R.id.text2 };
    simpleCursorAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, from, id, Adapter.NO_SELECTION);
    listView.setAdapter(simpleCursorAdapter);
}
Also used : DaoMaster(com.greendao.sql.DaoMaster) SimpleCursorAdapter(android.widget.SimpleCursorAdapter) Cursor(android.database.Cursor) DaoSession(com.greendao.sql.DaoSession)

Example 58 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project newsrob by marianokamp.

the class FeedListActivity method initialize.

private void initialize(Intent i) {
    dbQuery = UIHelper.createDBQueryFromIntentExtras(getEntryManager(), i);
    Cursor c = getEntryManager().getFeedListContentCursor(dbQuery);
    startManagingCursor(c);
    sca = new SimpleCursorAdapter(this, R.layout.dashboard_list_row, c, new String[] { "_id", "frequency", "sum_unread_freq" }, new int[] { R.id.item_title, R.id.item_count, R.id.unread });
    final int readIndicator = getEntryManager().isLightColorSchemeSelected() ? R.drawable.read_indicator : R.drawable.read_indicator_dark;
    sca.setViewBinder(new SimpleCursorAdapter.ViewBinder() {

        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            if (columnIndex == 2) {
                TextView tv = (TextView) view;
                boolean containsUnread = cursor.getInt(2) > 0;
                tv.setBackgroundResource(containsUnread ? readIndicator : R.drawable.read_indicator_invisible);
                return true;
            }
            return false;
        }
    });
    setListAdapter(sca);
    int noOfListRows = getListView().getAdapter().getCount();
    if (noOfListRows < 3 || dbQuery.getFilterFeedId() != null) {
        // all articles or just a single feed?
        getListView().performItemClick(getListView(), noOfListRows - 1, -1l);
        if (!isTaskRoot())
            finish();
    }
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter) TextView(android.widget.TextView) Cursor(android.database.Cursor) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView)

Example 59 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project android_frameworks_base by ResurrectionRemix.

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 60 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project android_frameworks_base by ResurrectionRemix.

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)

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