How to get the cursor index from an i

by michael.bollm...@googlemail.com » Sat, 07 Mar 2009 02:37:17 GMT


Sponsored Links
 Let's assume my cursor returns 100 items
I want to select the item that got the id 50
I assume that setSingleChoiceItems expects an index based on the
cursors
result not an id

So how do i convert the id to an result index without doing a costly
linear search

thanks
michael
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. how to detect longpress on touchscreen?

hi,everyone!
        Can anybody tell me that how to detect longpress on touchscreen and get 
the longpress-point's location in ImageView?I tried to use OnLongClickListener, 
but it seems that onTouchEvent  can not work when OnLongClickListener is set.
        I suffered this for days.Can anybody give me some advice? Thanks!
                                
--------------
Chenguo
2008-05-04



--~--~---------~--~----~------------~-------~--~----~

2. Mock location provider-gps1

Hi,

i created a mock location provider gps1, and

 myLocationManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
 lpObj = myLocationManager.getProvider("gps1");

DEBUG/(13685): zip_openZipFile(/data/app/LocationManager1.apk)
DEBUG/LocationManager(13685): getProvider: name = gps1
DEBUG/LocationManagerService(508): getProviderInfo: provider = gps1
DEBUG/LocationManagerService(508): loadProviders
DEBUG/LocationManagerService(508): loadProviders: already loaded
DEBUG/dalvikvm(508): Exception Ljava/lang/IllegalArgumentException;
from LocationManagerService.java:649 not caught locally
ERROR/JavaBinder(508): *** Uncaught remote exception!  (Exceptions are
not yet supported across processes.)
ERROR/JavaBinder(508): java.lang.IllegalArgumentException:
provider=gps1
ERROR/JavaBinder(508):     at
android.server.LocationManagerService.getProviderInfo(LocationManagerService.java:
649)
ERROR/JavaBinder(508):     at android.location.ILocationManager
$Stub.onTransact(ILocationManager.java:127)
ERROR/JavaBinder(508):     at
android.os.Binder.execTransact(Binder.java:274)
ERROR/JavaBinder(508):     at android.dalvik.NativeStart.run(Native
Method)
DEBUG/LocationProvider(13685): Constructor: name = gps1
DEBUG/dalvikvm(13685): Exception Ljava/lang/RuntimeException; from
ActivityThread.java:1758 not caught locally
DEBUG/dalvikvm(13685): Exception Ljava/lang/RuntimeException; from
ZygoteInit.java:1553 not caught locally
DEBUG/AndroidRuntime(13685): Shutting down VM
WARN/dalvikvm(13685): threadid=3: thread exiting with uncaught
exception (group=0x4000fdf8)
ERROR/AndroidRuntime(13685): Uncaught handler: thread Main exiting due
to uncaught exception
ERROR/AndroidRuntime(13685): java.lang.RuntimeException: Unable to
start activity ComponentInfo{org.me.locationmanager1/
org.me.locationmanager1.MyLocationManager}:
java.lang.NullPointerException
ERROR/AndroidRuntime(13685):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1758)
ERROR/AndroidRuntime(13685):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
1770)
ERROR/AndroidRuntime(13685):     at android.app.ActivityThread.access
$1500(ActivityThread.java:99)
ERROR/AndroidRuntime(13685):     at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1271)
ERROR/AndroidRuntime(13685):     at
android.os.Handler.dispatchMessage(Handler.java:80)
ERROR/AndroidRuntime(13685):     at android.os.Looper.loop(Looper.java:
91)
ERROR/AndroidRuntime(13685):     at
android.app.ActivityThread.main(ActivityThread.java:3052)
ERROR/AndroidRuntime(13685):     at
java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(13685):     at
java.lang.reflect.Method.invoke(Method.java:356)
ERROR/AndroidRuntime(13685):     at android.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:1547)
ERROR/AndroidRuntime(13685):     at
android.os.ZygoteInit.main(ZygoteInit.java:1445)
ERROR/AndroidRuntime(13685):     at
android.dalvik.NativeStart.main(Native Method)
ERROR/AndroidRuntime(13685): Caused by: java.lang.NullPointerException
ERROR/AndroidRuntime(13685):     at
android.location.LocationManager.createProvider(LocationManager.java:
61)
ERROR/AndroidRuntime(13685):     at
android.location.LocationManager.getProvider(LocationManager.java:119)
ERROR/AndroidRuntime(13685):     at
org.me.locationmanager1.MyLocationManager.onCreate(MyLocationManager.java:
30)
ERROR/AndroidRuntime(13685):     at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
847)
ERROR/AndroidRuntime(13685):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1728)
ERROR/AndroidRuntime(13685):     ... 11 more
INFO/Process(508): Sending signal. PID: 13685 SIG: 3
INFO/dalvikvm(13685): threadid=7: reacting to signal 3
INFO/dalvikvm(13685): DALVIK THREADS:
INFO/dalvikvm(13685): "Main" prio=5 tid=3 NATIVE
INFO/dalvikvm(13685):   | group="main" sCount=1 dsCount=0 s=0
obj=0x40010450
INFO/dalvikvm(13685):   | sysTid=496 nice=0 sched=0/0
handle=-1092584196
INFO/dalvikvm(13685):   at android.os.BinderProxy.transact(Native
Method)
INFO/dalvikvm(13685):   at
android.app.ActivityManagerProxy.handleApplicationError(ActivityManagerNative.java:
1441)
INFO/dalvikvm(13685):   at
android.os.RuntimeInit.crash(RuntimeInit.java:250)
INFO/dalvikvm(13685):   at android.os.RuntimeInit
$UncaughtHandler.uncaughtException(RuntimeInit.java:56)
INFO/dalvikvm(13685):   at
java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:853)
INFO/dalvikvm(13685):   at
java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:850)


showing illegal argument exception, means "gps1" is not recognizing as
a location provider, please tell the error..

--~--~---------~--~----~------------~-------~--~----~

3. findViewById() function return null

4. Thread and onCreate ?

5. Dear Android Developer Challenge losers,

6. Ringtones and SMS functions

7. Can you have two applications visible on screen at the same time?