Hi Rajesh,
when there is no data in the model then the empty view is shown, which I
think is correct.
Also I don't think I do any of the things you mentioned.
The only thing where I don't have a good feeling about is the following
method, that is run on the UI thread. It is called when the model is
updated, which may include a change to the query criteria:
private void updateCursor() {
if (dbQuery.hasChanged()) {
Timing t = null;
if (NewsRob.isDebuggingEnabled(this))
t = new Timing("ArticleListActivity.updateCursor() change of
cursor", this);
final Cursor oldCursor = listAdapter.getCursor();
if (oldCursor != null) {
stopManagingCursor(oldCursor);
listAdapter.notifyDataSetInvalidated();
oldCursor.close();
}
final Cursor cursor = getEntryManager().getContentCursor(dbQuery
);
startManagingCursor(cursor);
listAdapter.changeCursor(cursor);
if (t != null)
t.stop();
// listAdapter.notifyDataSetChanged();
} else {
Timing t = null;
if (NewsRob.isDebuggingEnabled(this))
t = new Timing("ArticleListActivity.updateCursor() requery",
this);
// listAdapter.notifyDataSetChanged(); doesn't work. use requery
// instead
listAdapter.getCursor().requery();
if (t != null)
t.stop();
}
}
But with the limited knowledge I have about the current issue, this code
doesn't seem like the culprit.But if you have a good idea about it, I am
very willing to listen.
?
On Mon, Nov 1, 2010 at 6:44 PM, Rajesh Kumar <[email protected]> wrote:
> Hello Mariano Kamp,
> *
> *
> *Usually This kind of exception comes when your are not closing cursor
> mainly when you press home key or End Key .Or doing delete operation on Same
> table which you are fetching data.*
> *Be ensure When there is No data in table for which you are retrieving
> data you display some toast and close activity or Display some TextView
> rather than ListView.
> *
> On Mon, Nov 1, 2010 at 11:05 PM, Mariano Kamp <[email protected]>wrote:
>
>> Any idea how I can get to the bottom of this?
>>
>> I am wondering if this error message means that the list view ask for the
>> number of rows in the list adapter, but during the rendering of the list
>> this number changes (is reduced). That code is not in my hand though.
>>
>> How would I deal with that?
>>
>> Currently I change the database on a background thread, send a
>> notification (notification in the generic sense, not an Android
>> notification) afterwards and the listeners that want to change the UI (like
>> refreshUI() form below) use runOnUiThread() to process the event.
>>
>> On Mon, Nov 1, 2010 at 5:34 PM, Romain Guy <[email protected]> wrote:
>>
>> This kind of error usually happens when there's a concurrency issue in
>> the application.
>>
>> On Mon, Nov 1, 2010 at 4:02 AM, Mariano Kamp <[email protected]>
>> wrote:
>> > Hi,
>> > I occasionally get exceptions like this one here:
>> > android.database.CursorIndexOutOfBoundsException: Index 0 requested,
>> with a
>> > size of 0
>> > at
>> android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
>> > at
>> >
>> android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:172)
>> > at
>> >
>> android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:99)
>> > at
>> android.database.AbstractCursor.moveToPosition(AbstractCursor.java:194)
>> > at android.widget.CursorAdapter.getView(CursorAdapter.java:177)
>> > at android.widget.AbsListView.obtainView(AbsListView.java:1254)
>> > at android.widget.ListView.measureHeightOfChildren(ListView.java:1142)
>> > at android.widget.ListView.onMeasure(ListView.java:1055)
>> > at android.view.View.measure(View.java:7117)
>> > at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2929)
>> > at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
>> > at android.view.View.measure(View.java:7117)
>> > at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2929)
>> > at
>> >
>> android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:888)
>> > at android.widget.LinearLayout.measureVertical(LinearLayout.java:350)
>> > at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
>> > at android.view.View.measure(View.java:7117)
>> > at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2929)
>> > at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
>> > at android.view.View.measure(View.java:7117)
>> > at android.widget.LinearLayout.measureVertical(LinearLayout.java:464)
>> > at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
>> > at android.view.View.measure(View.java:7117)
>> > at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2929)
>> > at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
>> > at android.view.View.measure(View.java:7117)
>> > at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2929)
>> > at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
>> > at android.view.View.measure(View.java:7117)
>> > at android.view.ViewRoot.performTraversals(ViewRoot.java:866)
>> > at android.view.ViewRoot.handleMessage(ViewRoot.java:1718)
>> > at android.os.Handler.dispatchMessage(Handler.java:99)
>> > at android.os.Looper.loop(Looper.java:123)
>> > at android.app.ActivityThread.main(ActivityThread.java:3948)
>> > at java.lang.reflect.Method.invokeNative(Native Method)
>> > at java.lang.reflect.Method.invoke(Method.java:521)
>> > at
>> >
>> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
>> > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
>> > at dalvik.system.NativeStart.main(Native Method)
>> > My own code isn't really touched in this stack trace and I am wondering
>> what
>> > I might be doing wrong here?
>> > I suspect it is something about the coordination of redraw/invalidation
>> > events, but I don't know where to look exactly.
>> > When I update the model (the sqlitedatabase) I run the following code on
>> the
>> > UI thread afterwards:
>> >
>> > void refreshUI() {
>> >
>> > ((BaseAdapter) getListAdapter()).notifyDataSetChanged();
>> >
>> > // the remaining calls are just included for completeness
>> >
>> > // they update different ui elements, but don't access the
>> cursor in
>> > any way.
>> >
>> > updateButtons();
>> >
>> > updateControlPanelTitle();
>> >
>> > updateProgressBar();
>> >
>> > }
>> >
>> > Any other information I can provide?
>> >
>> > Cheers,
>> >
>> > Mariano
>> >
>>
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Android Developers" group.
>> > To post to this group, send email to
>> [email protected]
>> > To unsubscribe from this group, send email to
>> > [email protected]<android-developers%[email protected]>
>> > For more options, visit this group at
>> > http://groups.google.com/group/android-developers?hl=en
>>
>> --
>> Romain Guy
>> Android framework engineer
>> [email protected]
>>
>> Note: please don't send private questions to me, as I don't have time
>> to provide private support. All such questions should be posted on
>> public forums, where I and others can see and answer them
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]<android-developers%[email protected]>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]<android-developers%[email protected]>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en