Android Question Sender Issue (I think)

shaffnert03

Member
Licensed User
Longtime User
Hi, I'm a new user so apologies if this is obvious. I haven't been able to find an answer in the forum.

Short version: I have a two column list in which sender is giving me numbers different from the list item clicked.

I'm taking the ScrollViewList discussed in one forum and trying to convert it to have multiple columns using as a guide code in http://www.b4x.com/android/forum/threads/list-with-two-columns-and-a-checkbox.7221/#post41354. I managed to get it converted to two columns, but when you click it weird things happen. Only clicking items in the left column has an impact, and if you click near the line between buttons it will highlight a right column item rather than left.

My bet here is that the sender is getting index numbers from a view that I haven't reoriented yet, but I'm new enough to not know where this is and be a bit mystified about it all, any help? Code attached, thanks in advance!
 

Attachments

  • ListUpload.zip
    8.9 KB · Views: 219

klaus

Expert
Licensed User
Longtime User
Erel is right !

But to give an ansewer to your problem.
The problems are:
1) you initialize in List_Add
Lab.Initialize("lblList")
and
Lab2.Initialize("lblList2")
You have two different EventNames but you don't have a lblList2_Click event, so when you click on a Label in the right column nothing happens !

2) You set as the Tags
Lab.Tag = NumberOfRows
Lab2.Tag = NumberOfRows & ".2)

You will get as the Tags for example for line 2 : left column Tag = 2 right column Tag = 2.2
Then in Sub List_Select(Item As Int) you transform the Tag into an integer so 2.2 becomes 2 !?
Then, still in Sub List_Select you set SelectedItem = Item which is already wrong.
The item indexes of the Labels in the ScrollView.Panel are the order number when you added them.
So the indexes are:
0 1
2 3
4 5
And not
0 0.2
1 1.2
2 2.2

To make it run correctly I changed:
Lab2.Initialize("lblList2") to
Lab2.Initialize("lblList")
Lab.Tag = NumberOfRows
to
Lab.Tag = 2 * NumberOfRows

Lab2.Tag = NumberOfRows to
Lab2.Tag = 2 * NumberOfRows + 1

Look at the changes I made in Sub List_Add.
Attached you find a modified version of your project.
 

Attachments

  • ListUpload_1.zip
    8.9 KB · Views: 187
Upvote 0

shaffnert03

Member
Licensed User
Longtime User
One followup question: I was using the example I had because another post mentioned it being better for sorting lists. If I switch to the CustomListView and want to be able to still sort/add/delete all the elements in each line as a unit is that still the best way? Or am I better sticking with the now corrected version of what I had? And why for either?
 
Last edited:
Upvote 0

shaffnert03

Member
Licensed User
Longtime User
NOTE! Since this is really a new problem I'm moving it to a new thread. Those who want to help more or follow can address the below issue at http://www.b4x.com/android/forum/threads/customlistview-extract-data.35108/. Thanks!

I took Erel's advice and am trying to use the CustomListView instead, which seems to cover my issues quite well. I'm having trouble with one aspect though. The list I was working with was already set up to move items up or down the list. I'm trying to create that function in the new one by deleting a line and adding it back above or below where it was, as the other did, but I don't know how to get the data out of the line I'm deleting first.

The file is attached, line 108 is my attempt to get the old data (which I would then feed in to the last line of that same sub), but it pulls out the line tag instead of the line values. If I browse the object in debug mode I can see the values I want in the 1, 2, and 3 objects of the array view in the x variable. How do I get these values back out to be able to submit them to the add line?
 

Attachments

  • MoveUpIssue.zip
    9.7 KB · Views: 208
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…