Showing record details

aklisiewicz

Active Member
Licensed User
Longtime User
I havea Listview which lists SQLite table records. When user selects a record (ShortClick) he is taken to another screen (Activity) where I wan to display record details. This particular record has also several ChildRecords so I would need to display child records either on the same screen or on another screen by pressing appropriate Button. another words on the DETAIL screen I will have several buttons to display ChilRecords (like CHIL1, CHIL2, CHILD3 etc.)

This is pretty much like DButils example App, however this App is like my secondary screen, so instead selecting students (like in this demo app) by using look-up list I want to have full featured Listview with the search capability and then after clicking on a record I want to go and display details.

Question:
I want user to come back to the same record (the one he had selected) after clicking BACK button on the device or eventually by selecting BACK button in the App.

Shall I read all record fields, store it in an Array and the pass it to the second Activity, or better pass only the RecordID parameter and re-read the record in the second Activity ?

What is the best method to do it ?

Arthur
 

Geezer

Active Member
Licensed User
Longtime User
I havea Listview which lists SQLite table records. When user selects a record (ShortClick) he is taken to another screen (Activity) where I wan to display record details. This particular record has also several ChildRecords so I would need to display child records either on the same screen or on another screen by pressing appropriate Button. another words on the DETAIL screen I will have several buttons to display ChilRecords (like CHIL1, CHIL2, CHILD3 etc.)

This is pretty much like DButils example App, however this App is like my secondary screen, so instead selecting students (like in this demo app) by using look-up list I want to have full featured Listview with the search capability and then after clicking on a record I want to go and display details.

Question:
I want user to come back to the same record (the one he had selected) after clicking BACK button on the device or eventually by selecting BACK button in the App.

Shall I read all record fields, store it in an Array and the pass it to the second Activity, or better pass only the RecordID parameter and re-read the record in the second Activity ?

What is the best method to do it ?

Arthur

I usually store the record number in Process_Globals and read the record from the new activity. This way I don't take up any more ram than I need to if i'm using a huge database.

Clicking back should return you to the original point.
 
Upvote 0

aklisiewicz

Active Member
Licensed User
Longtime User
Thank you for responding.
That is what I initially intendet to do, but I was wondering if there is any way to pass a RecordId variable when calling StartActivity("MyActivity") ?

OK, so you store the RocordNumber or you store PrimaryKey ID ?

when the user clicks a record certain record is selected.

Physical record and record stored in the temporary queue is not the same thing (right?). When I read records I iterate through the records to create recordset. In B4A (if I understand correctly) curent record is stored in a Cursor.

say, if I have:

Dim RecordId As INT


How would I read selected record into RecordId ?

Art
 
Upvote 0

eps

Expert
Licensed User
Longtime User
There is no need to store the value in Process Globals...

You need to pass in Position to the Click Sub on ListView. How are you populating the ListView? You need to use AddTwoLines2 or similar. You can then set the Value as the record identifier, then use this in the Click Sub to read only that record and all the details.


Populate using :

B4X:
ListView1.AddTwoLines2(Cursor.GetString("attrib1"), Cursor.GetString("attrib2"), Cursor.GetInt("_id"))

Select and show detail using :

B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
   'do something with the Position, some code or call another Sub, etc..
End Sub

Then you need to also (in your case) work out how you are going to process the Back Keypress and ensure that you return to where you've come from, or at least just send the Detail Info to the back or Remove. I'm not really sure how any of your code is structured, but this should give you the basis for what you want to achieve, I think.
 
Last edited:
Upvote 0

aklisiewicz

Active Member
Licensed User
Longtime User
this makes sense, but how do I pass the Cursor position to another activity ?

Arthur
 
Upvote 0

aklisiewicz

Active Member
Licensed User
Longtime User
Can you please pint me to some example of this ?

I see many example Apps but so far I was not able to find something simple which at least give me an idea of the process flow. What I'm looking for is:

SCENARIO
- List records from the database
- userClick on the record -> the record details form is showed up
- user LongClick on the record -> the Edit Form is opened up and user can edit fields, then Save the record
- userClick on INSERT button -> Blank Edit Form is opened where user can enter data and save it as a new record



SUGGESTION


It would be nice also to show how to create forms with variety of different field types i.e. MEMO(text field), Image(stored in file), image(stored in database), map location, URL-location and perhaps the same for the video

I've seen Apps which have most of those features implemented but everything is so fragmented and scattered that it takes tremendous amount of time to figure things out. On top of that searching for libraries and information is the weakest point of using B4A.

The scenario I described above is the most typical scenario I could imagine for any desktop or web App. such basic features should be implemented and showed as a first step to learn using databases with B4A.
Klaus has created several nice Apps and probably did the best he could to introduce SQLite etc but he did everything from his (I would call it EXPERT) point of view. For most people those things are not as clear as for experienced developers. Therefore the best way to help people use and learn B4A is to ask them first what parts of the system are hard to grasp and make examples towards those requests. Usually what seems necessary for expert developer is not necessary for a novice. I would really like to see all examples more coherent and more like finished Applications.
I would suggest to create list of HOW TO's and let the users edit this list. This way we would get an answers to simple questions which are repeated here on this forum over and over again.
Since B4A introduces external libraries, classes and Types, there is unlimited amount of freedom on creating new classes, types etc. For that reason the documentation and easy navigation is crucial. Those who make manuals, documentation and examples have to also keep in mind that many people coming here from non Object Oriented languages, and some people are simply starting programing from ground zero and have no knowledge of OO at all.
 
Upvote 0

aklisiewicz

Active Member
Licensed User
Longtime User
You can use CallSubDelayed to pass any object.
Perhaps I could use it but I don't know how because the information on parameters is incomplete.
I'm also confused about the difference between passing and Object and passing the Value as parameter and see no resource to learn about it.

Arthur
 
Upvote 0

aklisiewicz

Active Member
Licensed User
Longtime User
Here is a line from your code example:

CallSubDelayed2(Activity2,
"ShowList", "This is the title")

There are 3 parameters. While the 1st and 3rd are selfexplanatory the 2nd is not.
I assume it is a Sub name but you do not explain which Sub in a calling module shall I list as a parameter.
This is confusing part. If I have a module with several Sub's in it then which one ?
The example you pinting to has everything in one module. I have an App with separate modules. I tried few options but it doesn't work for me.

Art


 
Upvote 0

aklisiewicz

Active Member
Licensed User
Longtime User
what an impass? you don understand and I don't understand :-(
Once again my question is - which Sub I need to choose in the called module ? Should it be the first which is normally executed ?

I still have problem selecting a record and displaying the contents (even using old method). For Some reason I get no Error compiling but the data is not shown in the detail screen.

Arthur
 
Last edited:
Upvote 0
Top