B4J Question TableView_SelectedRowChanged error

atiaust

Active Member
Licensed User
Longtime User
Hi All,

I am experiencing a "java.lang.NullPointerException" on a TableView_SelectedRowChanged(Index As Int, Row() As Object).

I have a large data input form that has some buttons used for searching a Mysql database.
When a search button is clicked the search parameters is passed to another code module 'SearchForm' which opens and shows the results of the search via a TableView. Below the TableView are some text fields that show the details of the selected row from the tableview. The selected details are returned to the calling module and the SearchForm' is closed.

This all works well the first time the search is conducted however on the next search the 'SearchForm' loads and executes the database search displaying the results. For some reason I can't explain the TableView_SelectedRowChanged(Index As Int, Row() As Object) is triggered without me selecting anything and that triggers the "java.lang.NullPointerException" error and crashes the app.

Anyone have any ideas.

Thanks

I have tried without success..
B4X:
Dim jo As JavaObject = tvMytable
    jo.RunMethodJO("getSelectionModel",Null).RunMethod("clearSelection",Null)
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
This

B4X:
 TableView_SelectedRowChanged(Index As Int, Row() As Object)

will be triggered, when you clean, delete or do something with the tableview, that means that you should add something like:

B4X:
If index = -1 then
return
end if
 
Upvote 0

atiaust

Active Member
Licensed User
Longtime User
Thanks, That did the trick.

I thought it may have been something like that and I tried to get the value of the index with a log message but it crashed before it wrote to the logs.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…