android-cursoradapter

Limit number of rows in Cursor query

☆樱花仙子☆ 提交于 2020-01-04 04:12:06
问题 I need to get contacts from an android phone. so I am using this code: Cursor phones = getActivity().getContentResolver().query(Phone.CONTENT_URI, new String[] { Phone.NUMBER, Phone.TYPE }, " DISPLAY_NAME = ?", new String[] { displayName }, null); while (phones.moveToNext()) { //do work here } I want to tell the cursor to limit the response to 50 with something like "LIMIT 50". Where do I pass that information to the cursor? Please copy and paste my code and make edit there. 回答1: There is no

How to dynamically add suggestions to autocompletetextview with preserving character status along with images

对着背影说爱祢 提交于 2020-01-03 03:37:48
问题 Currently I am using code to give text suggestion. I would like to add another text and image. How do I do that? Currently, I am using the code below.I shows text but image is not displayed .How do I set the image ? public class AutoCompleteTextViewActivity extends Activity{ ImageLoader imageLoader; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder(

IllegalStateException: database already closed (using ViewPager)

蹲街弑〆低调 提交于 2020-01-02 04:44:09
问题 I'm stumped as to what is causing this error, as I have made sure that I am closing my database adapter properly (at least I think I am). Here's what LogCat's saying (the tag for all of them is AndroidRuntime): FATAL EXCEPTION: main java.lang.IllegalStateException: database /data/data/com.acedit.assignamo/databases/data.db (conn# 0) already closed at android.database.sqlite.SQLiteDatabase.verifyDbIsOpen(SQLiteDatabase.java:2082) at android.database.sqlite.SQLiteDatabase.lock(SQLiteDatabase

How to keep checkbox selection in cursor adapter when switching cursor?

断了今生、忘了曾经 提交于 2019-12-31 07:30:29
问题 I have a ListView that I'm populating with information from the media store. I have checkboxes on each row to allow the user to select multiple rows. In the options menu, there are menu items that trigger new queries to the media store and using a CursorLoader i swap the cursor in the adapter when the cursor has loaded. In my adapter I'm using an ArrayList that keeps track of the checked items and one that keeps track of all items in the list. The list that keeps track of all items needs to

How to pull data from database and view them as a ListView

一个人想着一个人 提交于 2019-12-25 14:00:39
问题 I am using a custom list adapter for my ListView. My each list item has 4 items. which are come from a listArray. Here is the code which pull the list items from List Array. import android.app.Fragment; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ListView; import com.rupomkhondaker.sonalibank.adapter

Create cursor loader from two datasources?

你。 提交于 2019-12-25 09:24:23
问题 I have a method that queries a database table via a provider and returns a CursorLoader to be used to populate a UI via a CursorAdapter . I need in one particular case only to add some extra data that are not part of the database result set. Is there a way to somehow for that case add some extra "fake" rows with the data? Like creating a cursor loader from two data sources? 回答1: Yes. Use MatrixCursor to add some "fake" rows. Then merge the two cursors (CursorAdapter, MatrixCursor) using the

How to get getItemAtPosition in getView?

本秂侑毒 提交于 2019-12-25 06:14:09
问题 I have ImageView with listItems from db, and every list items have two Buttons (add friend/rejectFriend). I am also using CursorAdapter , and inside of my adapter I have getView() method to set listeners and catch clicks on current item Button . and here the question: I need to get some data from db for current item, when i catch click on item Button (add friend for example). so with help of getView() parameters I can get the position of ListView item, but how from getView() correct call

SQlite primary key field name & CursorAdapter subclasses

爱⌒轻易说出口 提交于 2019-12-25 04:19:10
问题 Why do CursorAdapter subclasses requires the primary key to be necessarily _id ? Isn't there a method to override, or something like that, to change this behaviour ? I have read this trick many times, and I am aware of that ... I just want to understand better ! Thanks 回答1: Why does CursorAdapter subclasses requires the primary key to be necessarily _id ? It turns around and provides that value in various places, such as the long id value in getView() . Isn't there a method to override, or

Implementing own Android CursorAdapter for search suggestions - unknown exceptions

依然范特西╮ 提交于 2019-12-25 03:13:23
问题 I have implemented my own cursor adapter to manually handle suggestions, so that I can get rid of the overkill method that android docs proposes. Basically what I do is setOnQueryTextListener to the actionbar searchview after it's been inflated. Everytime the user inputs a new search text, I query a Sqlite db which returns a cursor. Finally, I create my own cursor adapter with the retrieved cursor and set it to the searchview with setSuggestionsAdapter method. The problem here is that I am

Implementing own Android CursorAdapter for search suggestions - unknown exceptions

眉间皱痕 提交于 2019-12-25 03:13:15
问题 I have implemented my own cursor adapter to manually handle suggestions, so that I can get rid of the overkill method that android docs proposes. Basically what I do is setOnQueryTextListener to the actionbar searchview after it's been inflated. Everytime the user inputs a new search text, I query a Sqlite db which returns a cursor. Finally, I create my own cursor adapter with the retrieved cursor and set it to the searchview with setSuggestionsAdapter method. The problem here is that I am