Android Question clv click

Almora

Active Member
Licensed User
Longtime User
hi..

B4X:
Sub Clv1_ItemClick (Index As Int, Value As Object)
 
    Log("index = "&Index)
 
End Sub

when i click the first line
index = 0

when i click the last line
index =4


How can I reverse this process?
when i click the first line
index = 4 ---->>???

when i click the last line
index =0 ---->>???
 

Attachments

  • Screenshot_20230501-031219.png
    Screenshot_20230501-031219.png
    25.1 KB · Views: 70

Mahares

Expert
Licensed User
Longtime User
How can I reverse this process?
What is the purpose of reversing the process. It can be very confusing when you are jumping to items other than the first and last. Could you explain why you would want to do that and under what condition. Is this only a curiosity question, it seems to me that it is best to sort the data highest to lowest to display and use xClv item click the way it is supposed to be used.
 
Upvote 0

Almora

Active Member
Licensed User
Longtime User
What is the purpose of reversing the process. It can be very confusing when you are jumping to items other than the first and last. Could you explain why you would want to do that and under what condition. Is this only a curiosity question, it seems to me that it is best to sort the data highest to lowest to display and use xClv item click the way it is supposed to be used.
hello when reading data with sqlite, the last record remains at the beginning. it's about this. the first and last items are not skipped.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
when reading data with sqlite, the last record remains at the beginning. it's about this. the first and last items are not skipped.
Hello: I am sorry, I really do not understand what you mean. Can you post the query and some of the code that does that to see how the records are displayed in the xClv.
 
Upvote 0

Almora

Active Member
Licensed User
Longtime User
Hello: I am sorry, I really do not understand what you mean. Can you post the query and some of the code that does that to see how the records are displayed in the xClv.
* i am recording data with sqlite.
* i'm showing the data with clv.
* the last one I saved appears at the top of the list.
* but for some reason the first data starts with id=3. (!)
* if I click on the first one in the list, it will show the last one.
* the list should scroll the lines.

i use translation, I may not be able to explain it completely..
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Without seeing your code it is impossible to give any concrete advice.
The best way to help you would be if you posted a small project showing the problem.
That way we can see what you have done and how and give you a solution.
 
Upvote 0

Almora

Active Member
Licensed User
Longtime User
hi.
I added an example.
my problems.
1- More than two records sometimes do not show in the list.
2- When I click on the first row in the list, it shows that I saved it in the last row.
3- when I drag the list order it doesn't give the correct result.
 

Attachments

  • test1.zip
    21.8 KB · Views: 40
Last edited:
Upvote 0

Almora

Active Member
Licensed User
Longtime User
I had a look at your project.
Sorry, but i do not understand what you want to do nor what exactly you expect.
I need some more detailed explanations.
Please explain step by step what to do and what you expect.
you need to run the project. i'm making recordings to the sqlite file. but he does not record recordings regularly. problems occur with more than two records. and when I drag the list order, it does not give the correct result.
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
A suggestion: do not use the index as the row id o fthe record. Save the row id of the record in the Value part of the clv.add method.

That way it does not matter the order of display or even if the records in the database are not contiguous (which is likely to happen if items are deleted)
 
Upvote 0

Almora

Active Member
Licensed User
Longtime User
I explained with pictures. my english is insufficient.
 

Attachments

  • 1.jpg
    1.jpg
    138.9 KB · Views: 57
  • 2.jpg
    2.jpg
    180.2 KB · Views: 52
  • 3.jpg
    3.jpg
    209.1 KB · Views: 60
  • 4.jpg
    4.jpg
    111.3 KB · Views: 53
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
I explained with pictures. my english is insufficient.
I fixed some bugs in the project.
in my opinion you are making a simple task to complicated. you also use activities and read data from 1 activity to another what is wrong to do because you cannot expect the activity to stay always in forground. you should use either b4xpages or use a single activity.

you Select entry from the sql db by ID but i dont see you inserting the id to the DB? is it a Auto incremental Value? and primary key?
i think the problem is with the ID that is updated in the Map and List.

If you can explain what you want to archive i am sure we can write for you simple example.
(i dont mean to explain what your app does, just explain what you want to archive?)
for me it looks like you want to have data in a sql db and show them in a CLV. for this you dont need another map or list just read from the db and update the db only and always reload the clv.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
When you add new lines, you add those to the database.
But when you go to the list Activity you do not update it, you read it once in activity create FirstTime = True.
Remove If FirstTime Then and its End If.

For the inversion of the items shown have been already explained.
The selectedid in list1 is not the same as the id in the database.
 
Upvote 0
Top