android-viewbinder

Using SimpleCursorAdapter.ViewBinder to change the color of TextView

☆樱花仙子☆ 提交于 2019-12-01 00:03:52
I'm developing an alarm clock app for android and I want to have displayed list of alarms on the main screen. Each row of this ListView is defined in xml file. And I want to have separate TextViews for each day of week. Program will check in sqlite db if for eg. value for monday is = 1 and then change color of this TextView to red. I have written this code, but that doesn't work. What's wrong? private void fillData() { // Get all of the notes from the database and create the item list Cursor c = db.fetchAllAlarms(); startManagingCursor(c); String[] from = new String[] { db.KEY_TIME, db.KEY

Using SimpleCursorAdapter.ViewBinder to change the color of TextView

不问归期 提交于 2019-11-30 19:32:39
问题 I'm developing an alarm clock app for android and I want to have displayed list of alarms on the main screen. Each row of this ListView is defined in xml file. And I want to have separate TextViews for each day of week. Program will check in sqlite db if for eg. value for monday is = 1 and then change color of this TextView to red. I have written this code, but that doesn't work. What's wrong? private void fillData() { // Get all of the notes from the database and create the item list Cursor

Custom list clicking with checkboxes

好久不见. 提交于 2019-11-30 13:36:44
I've populated a ListActivity from a Cursor using SimpleCursorAdapter that starts another activity when one of the list items have been clicked. I'm also using ViewBinder to do some custom transformation of the data. I want to add a CheckBox to each row in the list so I've changed the view and added a CheckBox with gravity right. Adding the CheckBox has removed the ability to click on the items. The onListItemClick method I was overriding in ListActivity is no longer called when you press on a list item. Removing the CheckBox fixes this. Why is this? Also, how can I set up the list so that it

Displaying dates in localized format on Android

☆樱花仙子☆ 提交于 2019-11-28 19:19:46
I'm currently building my first app for Android. What I'm having trouble with is the storage and localized display of dates in connection with a SimpleCursorAdapter . I have a class that encapsulates access to an SQLitedatabase with three tables. This class takes care of storing all dates in ISO format ("yyyy-MM-dd"). When the date values are read from the database and displayed on the screen I want them to be formatted in a localized format. Here's the approach I've come up with. It uses a ViewBinder to do the formatting: adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override

Images in SimpleCursorAdapter

陌路散爱 提交于 2019-11-27 15:15:06
I'm trying to use a SimpleCursorAdapter with a ViewBinder to get an image from the database and put it into my ListView item view. Here is my code: private void setUpViews() { mNewsView = (ListView) findViewById(R.id.news_list); Cursor cursor = getNews(); SimpleCursorAdapter curAdapter = new SimpleCursorAdapter( getApplicationContext(), R.layout.cursor_item, cursor, new String[] { "title", "content", "image" }, new int[] { R.id.cursor_title, R.id.cursor_content, R.id.news_image }); ViewBinder viewBinder = new ViewBinder() { public boolean setViewValue(View view, Cursor cursor, int columnIndex)

Displaying dates in localized format on Android

匆匆过客 提交于 2019-11-27 12:14:07
问题 I'm currently building my first app for Android. What I'm having trouble with is the storage and localized display of dates in connection with a SimpleCursorAdapter . I have a class that encapsulates access to an SQLitedatabase with three tables. This class takes care of storing all dates in ISO format ("yyyy-MM-dd"). When the date values are read from the database and displayed on the screen I want them to be formatted in a localized format. Here's the approach I've come up with. It uses a

Modifying SimpleCursorAdapter's data

左心房为你撑大大i 提交于 2019-11-27 01:37:35
问题 I'm working on a TV Guide app which uses a ListActivity showing the TV shows for one channel / one day at a time. I'm using a RelativeLayout for the ListView items and I want the ListView to look something like this: 07:00 The Breakfast Show Latest news and topical reports 08:00 Tom and Jerry More cat and mouse capers I get the data for the ListView items using the following code: Cursor cursor = db.rawQuery(SELECT blah,blah,blah); String[] columnNames = new String[]{"start_time","title",

Images in SimpleCursorAdapter

为君一笑 提交于 2019-11-26 17:05:42
问题 I'm trying to use a SimpleCursorAdapter with a ViewBinder to get an image from the database and put it into my ListView item view. Here is my code: private void setUpViews() { mNewsView = (ListView) findViewById(R.id.news_list); Cursor cursor = getNews(); SimpleCursorAdapter curAdapter = new SimpleCursorAdapter( getApplicationContext(), R.layout.cursor_item, cursor, new String[] { "title", "content", "image" }, new int[] { R.id.cursor_title, R.id.cursor_content, R.id.news_image }); ViewBinder