android-loader

Android TabsAdapter with ActionbarSherlock

半腔热情 提交于 2019-12-22 08:39:10
问题 I am using ActionbarSherlock with a SherlockListFragment that implements LoaderManager.LoaderCallbacks . In my ApplicationActivity onCreate method I am using setContentView(R.layout.application); to set the layout -- works great. I am initializing the actionbar like so ActionBar bar = getSupportActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); bar.setDisplayHomeAsUpEnabled(false); bar.setDisplayShowTitleEnabled(true); /

Android - onLoadFinished not called

本秂侑毒 提交于 2019-12-21 09:27:52
问题 I am facing an issue with Loader. I have an Activity, which displays list of records retrieved from local DB. When the activity starts, records are automatically loaded via LoaderManager.initLoader() method. There is also possibility to manually refresh the list via refresh button in ActionBarSherlock. However, after finishing another activity which adds a record to DB, onLoadFinished is not called. I am using SimpleCursorLoader and here is code snippet from the activity: @Override public

Is using AsyncTask still recommended for loading listView items in the background?

随声附和 提交于 2019-12-21 02:28:36
问题 Background I've heard that there are some new solutions for loading data in the background which are more recommended than AsyncTask (like loaders). The problem AsyncTasks are great and easy to use. However, it has some limitations: The class itself has to be modified since it's limited by the number of pending tasks (about 256 or so). Of course, in a listView's adapter, I always cancel a task if it's not needed(for example when I need to update a view that was used for a different item). I

Android CursorLoader with selection and selectionArgs[]

孤街浪徒 提交于 2019-12-14 02:17:47
问题 I am using Loader for RecyclerView.Adapter to list items. I want to list specific items from database table. So i did: public Loader<Cursor> onCreateLoader(int id, Bundle args) { String selectionArgs1[]={"1","13","14"}; String selection1 = DatabaseOpenHelper.COLUMN_ID + " in ("; for (int i = 0; i < selectionArgs1.length; i++) { selection1 += "?, "; } selection1 = selection1.substring(0, selection1.length() - 2) + ")"; String[] projection1 =... return new CursorLoader(getActivity()

Load More - Only the original thread that created a view hierarchy can touch its views

一世执手 提交于 2019-12-11 18:56:33
问题 My app is using GridView to get image from JSON. Everything is ok but now I want to make it for loading more by clicking on button. I followed this tutorial Android ListView with Load More Button. When I followed it, I used runOnUiThread(new Runnable() { public void run() { } } in the doInBackground but it errors NetworkOnMainThreadException i knew this cuz I run it on UI thread. but when I remove runOnUiThread... , it errors also How can I fix this error? full source http://pastie.org

Get phone number from contact loader in android: projection crash

人走茶凉 提交于 2019-12-11 13:33:38
问题 I am using the sample code from the Google tutorial. The projection is where I specify the data I want to collect. How do I specify that I want the phone numbers ? The sample from Google does not get phone number. But I want to obtain the phone number, so I add the field for Phone.NUMBER . But when I do, the app always crashes. Here is my projection. // The projection for the CursorLoader query. This is a list of columns that the Contacts // Provider should return in the Cursor. @SuppressLint

Update ListView based on SQLite backed ContentProvider

邮差的信 提交于 2019-12-11 01:24:32
问题 I'm a new Android Developer and seem to have gotten in a little over my head. I am trying to make a listView update when I add more content to the list. The ListView is based off of a SQLite database. I was able to get the ListView to be based on the SQLite database by making a ContentProvider for the SQLite database (which was suggested here). Now my issue is that I want to update the SQLite database and have it reflected on the ListView. I am using a loader and according to this if I

onLoadFinished not called on offscreen fragment until going back

淺唱寂寞╮ 提交于 2019-12-10 18:54:20
问题 I'm trying to implement List->Detail scheme with details pagination. I've single Activity for ListView and different Activity with ViewPager. In FragmentStatePagerAdapter.getItem i instatniate new fragment for page and pass item id via setArguments Bundle. After opening pager Activity two Fragment pages are created and onCreate, onCreateView, onActivityCreated being called. BUT onLoadFinished is called only for first Fragment (currently visible). If i go back onLoadFinished is called for

IllegalStateException “attempt to re-open an already-closed object” in SimpleCursorAdapter from ContentProvider

谁说胖子不能爱 提交于 2019-12-10 15:14:01
问题 I have a series of ListView objects in Fragment s that are being populated by a CursorAdapter which gets a Cursor from the LoaderManager for the activity. As I understand it, all database and Cursor close actions are completely handled by the LoaderManager and the ContentProvider , so at no point in any of the code am I calling .close() on anything. Sometimes, however, I get this exception: 02-19 11:07:12.308 E/AndroidRuntime(18777): java.lang.IllegalStateException: attempt to re-open an

Loader framework and activity lifecycle

北城余情 提交于 2019-12-10 10:18:09
问题 I really like loaders and their benefits. But i meet a problem which i don't know how to solve. In my activity i use AsyncTaskLoader to load some data from database and provide cursor to the onLoadFinished(Loader<Cursor> loader, Cursor cursor) method which is implemented by activity. Problem is that onLoadFinished() does not called when activity is in onStop() state (not finishing()) e.g. incomming call occure. @Override protected void onCreate(Bundle bundle) { super.onCreate(bundle);