use of android.widget.SimpleCursorAdapter in project cw-omnibus by commonsguy.
the class VideosFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
String[] from = { MediaStore.Video.Media.TITLE, MediaStore.Video.Media._ID };
int[] to = { android.R.id.text1, R.id.thumbnail };
SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(), R.layout.row, null, from, to, 0);
adapter.setViewBinder(this);
setListAdapter(adapter);
getLoaderManager().initLoader(0, null, this);
}
use of android.widget.SimpleCursorAdapter in project android_frameworks_base by ParanoidAndroid.
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 android_frameworks_base by ParanoidAndroid.
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 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();
}
}
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);
}
Aggregations