simplecursoradapter

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",

how to display contacts in a listview in Android for Android api 11+

跟風遠走 提交于 2019-11-26 22:16:43
问题 I'm sorry if this looks like the same question a million times...but a google search for this provides no results, just a bunch of outdated tutorials using managedQuery and other deprecated solutions... I went through the android developer training for retrieving a contact list, but the tutorial is incomplete and even downloading the sample code doesn't help because the sample code is for more advanced contact list manipulation (search, etc.) In any case, there is no reason why there should

Android, using SimpleCursorAdapter to set colour not just strings

房东的猫 提交于 2019-11-26 21:20:45
问题 I have a simple cursor adapter set on a list in my application as follows: private static final String fields[] = {"GenreLabel", "Colour", BaseColumns._ID}; datasource = new SimpleCursorAdapter(this, R.layout.row, data, fields, new int[]{R.id.genreBox, R.id.colourBox}); R.layout.row consists of two TextViews (genreBox and colourBox). Rather than setting the content of the TextView to the value of "Colour" , I would like to set its background colour to that value. What would I need to do to

SimpleCursorAdapter how to show an image?

故事扮演 提交于 2019-11-26 21:05:32
问题 I am making an android recipes application where i use a database. In database there is a column named" "images", where i store the name of the file of the picture of the recipe where i store at drawable folder. Now i want to make a List with the recipes, showing: 1) the Title of the recipe 2) a short description and 3) an image of the recipe To do that i use a Simplecursoradaptor. My problem is i can not show the image. I want to read the file name from the column "images" and then set the

how do i create a custom cursor adapter for a listview for use with images and text?

微笑、不失礼 提交于 2019-11-26 19:39:39
问题 Hi want to create a custom cursor adapter so I can display an image with 2 lines of text. I have had some trouble understanding the custom cursor adapters but I do not understand how to add an imageview to be filled from the path in my database. 回答1: Will, I've actually implemented something incredibly similar to what you are looking for. Here is my implementation. import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android

Android: Using SimpleCursorAdapter to get Data from Database to ListView

爷,独闯天下 提交于 2019-11-26 18:45:27
I am programming an android app that should use a database to store data and read from it. Using this tutorial (on archive.org) I got the app to create a database and I'm able to create new entries, however, I don't know, how to read the database to get the stored data in a ListView. I know there are many similar questions on this website but it seems none of them apply to the way, the database from the tutorial works. Code: import java.util.Calendar; import maturarbeit.nicola_pfister.studenttools.database.DBAdapter; import android.app.AlertDialog.Builder; import android.app.ListActivity;

Get selected item from ListView bound with SimpleCursorAdapter

戏子无情 提交于 2019-11-26 17:58:28
问题 I'm brand new to Android development... coming from iPhone and .Net background. I've seen very similar questions to this one, but none of them dealt with the SimpleCursorAdapter. I have a basic ListActivity which uses a Cursor to bind data from a SQLite query to my ListView: ListAdapter adapter = new SimpleCursorAdapter( this, android.R.layout.simple_list_item_1, c, new String[] {"name"}, new int[] {android.R.id.text1}); setListAdapter(adapter); Then when an item is clicked: public void

SimpleCursorAdapter deprecated in API version 15?

别说谁变了你拦得住时间么 提交于 2019-11-26 17:47:09
问题 SimpleCursorAdapter deprecates one of its constructors with the following comment: Deprecated. This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even Application Not Responding errors. As an alternative, use android.app.LoaderManager with a android.content.CursorLoader. Does this make the whole class deprecated? The other (standard) constructor is not deprecated. 回答1: Only the constructor is

Using the recyclerview with a database

无人久伴 提交于 2019-11-26 11:30:33
Currently there is no default implementation of RecyclerView.Adapter available. May be with the official release, Google will add it. Since there is no support for CursorAdapter with the RecyclerView currently, how can we use a RecyclerView with a database ? Any suggestions ? skyfishjy If you are running a query with a CursorLoader and you want RecyclerView instead of ListView . You can try my CursorRecyclerViewAdapter : CursorAdapter in RecyclerView My solution was to hold a CursorAdapter member in my recyclerView.Adapter implementation. Then passing all the handling of creating the new view

AlphabetIndexer with Custom Adapter managed by LoaderManager

╄→尐↘猪︶ㄣ 提交于 2019-11-26 11:23:19
I am trying to implement AlphabetIndexer with Custom Adapter like this AlphabetIndexer with Custom Adapter My class ContactsCursorAdapter extends SimpleCursorAdapter and implements SectionIndexer and I am using a LoaderManager to manage my adapter's cursor so i have overridden the swapCursor() method like the second answer to the example above indicates. public class ContactsCursorAdapter extends SimpleCursorAdapter implements SectionIndexer{ private LayoutInflater mInflater; private Context mContext; private AlphabetIndexer mAlphaIndexer; public ContactsCursorAdapter(Context context, int