Android Question Closed: searchview is 99% OK for me.

anOparator

Active Member
Licensed User
Longtime User
From SearchView:
B4X:
Public Sub lv_ItemClick (Position As Int, Value As Object) 
	etCLas.Text = Value
	etCLas.SelectionStart = etCLas.Text.Length
	ime.HideKeyboard
	lv.Visible = True
	If SubExists(mCallback, mEventName & "_ItemClick") Then
		CallSub2(mCallback, mEventName & "_ItemClick", Value)
	End If

	Starter.curSpA = Starter.SQL1.ExecQuery2("SELECT id FROM tableName WHERE Col3 = ?", Array As String(etCLas.Text))  
	' Cursor will hold  ALL values and row which are fetched with this query
	' Here only one result is expected....
	' set the cursor position
	If Starter.curSpA.RowCount = 1 Then		' WAS a 1
		' set the cursor position
		Starter.curSpA.Position = 0
		Main.nMm = $"${Starter.curSpA.GetInt("id")}"$
		Log("whatz the SearchView ID " & $"${Starter.curSpA.GetInt("id")}"$)	'  **********
			Else
		Log("etCLas.BBBBB " & $"${etCLas.Text}"$)		
	End If
	Log("  ")
	Log("WHAT IS pgnm " & pgnm)
	CallSub(Main, "nme")
	etCLas.Text=""
	CallSub(Main, "clrPanlSrch")
End Sub
Will someone please tell me why this query would only fail on rowID 48?
I have re-created the db with SQLite, copied the values from the Searchview list into Col3, renamed the project, and even used a different image on row# 48.

The query finds the ID number of the image name typed into SearchView.et. Of the 101 images in the db table only #48 fails, now with 'Java.Lang.InvocationTargetException' error.
Have gotten the Exception.. IndexOutOfBounds also, and only on rowID #48.
banging head, thanks in advance.
 

anOparator

Active Member
Licensed User
Longtime User
B4X:
LogCat connected to: 2a20a0a
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
Copying updated assets files (14)
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **       '<< See next line >>
Class not found: com.oper8or.myAdinkraBg.searchview, trying:com.oper8or.myAdinkBg.searchview
Index time: 297 ms (101 Items)
RT RT RT ### = 0
** Activity (main) Resume **
whatz the SearchView ID 24                   'Query finds SearchView1.etCLas.Text
WHAT IS pgnm 0
whatz the SearchView ID 32                   'Query finds SearchView1.etCLas.Text
WHAT IS pgnm 0
whatz the SearchView ID 101                 'Query finds SearchView1.etCLas.Text
WHAT IS pgnm 0
whatz the SearchView ID 71                   'Query finds SearchView1.etCLas.Text
etCLas.BBBBB odo nyera fie kwan                ' ** rowID = 48 , Query fails ** odo nyera fie kwan 'DOES' = SearchView1.etCLas.Text as expected.
Error occurred on line: 80 (SearchView)   
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 0   '<<<
   at android.database.AbstractCursor.checkPosition(AbstractCursor.java:426)
   at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
   at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:68)
   at anywheresoftware.b4a.sql.SQL$CursorWrapper.GetInt(SQL.java:337)
   at com.oper8or.myAdinkBg.searchview._lv_itemclick(searchview.java:528)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
   at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
   at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
   at anywheresoftware.b4a.BA$1.run(BA.java:303)
   at android.os.Handler.handleCallback(Handler.java:733)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:136)
   at android.app.ActivityThread.main(ActivityThread.java:5095)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
   at dalvik.system.NativeStart.main(Native Method)
B4X:
   If Starter.curSpA.RowCount = 1 Then
     ' set the cursor position
     Starter.curSpA.Position = 0
     Main.nMm = $"${Starter.curSpA.GetInt("id")}"$
     Log("whatz the SearchView ID " & $"${Starter.curSpA.GetInt("id")}"$)
     Starter.curSpA.Position = 0
       Else
     Log("etCLas.BBBBB " & $"${etCLas.Text}"$)   
     pgnm = $"${Starter.curSpA.GetInt("id")}"$                                   'line 80, only when 'IF' fails
   End If
The searchView class is there.
pgnm is an Int that updates pgLbl.Text
 

Attachments

  • LINE_80.JPG
    119.1 KB · Views: 254
Last edited:
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
OhK.
and I removed/added SearchView to clear the 'ClassNotFound' mssg.
Cover me , I'm going back in
 
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
150 plus images, went from #47 to #49. Time for a new keyboard.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…