Android Question (solved) ADP with multiple pickers

sanjibnanda

Active Member
Licensed User
Longtime User
In which way doesn't it work? What is the output?
as per your suggestion i created desried ADPs at run time like this.( it works..)
B4X:
Pickers(y) = adp
 
Pickers(y).AddToActivity(Activity, VM4.GetView("sDate"&y))
 
VM4.AddButton(-2, -1, -1, 1, "sDateBtn"&y, "Set Date", 16, Colors.Black, "sDate_Click", Me)
the problem is with view manager "sDate_Click", i am unable to find its sender/tag

if i am able to get it, then particular ADP intance can be shown with

B4X:
Pickers(sender).show

as this works..Pickers(1), Pickers(2)...etc
B4X:
Sub sDate_Click

Pickers(1).Show
  
End Sub
 
Upvote 0

Straker

Active Member
Licensed User
Longtime User
tried it like this
B4X:
Dim checkValue As  AnotherDatePicker
    checkValue = Sender
    Log(checkValue)

but failed, please help as i am stuck here

How do you discern one picker from another?
If for example your original pickers have a Tag with 'Pic1', 'Pic2' and so on, the 3rd line of your code will something like

If checkValue.Tag = "Pic1" then...
 
Upvote 0

sanjibnanda

Active Member
Licensed User
Longtime User
How do you discern one picker from another?
If for example your original pickers have a Tag with 'Pic1', 'Pic2' and so on, the 3rd line of your code will something like

If checkValue.Tag = "Pic1" then...

please see my above post, the problem is to get the sender from buttons created at runtime with view manger class.
i want to catch that which button is clicked so that related ADP may be shown that is linked with its parent.
presently any button clicks fill the last view and its tag is used for CallSubDelayed(tagActionSub.ActionSubModule, tagActionSub.ActionSub).
 
Upvote 0

Straker

Active Member
Licensed User
Longtime User
I've downloaded and tested your adpTest.zip
In that source you are using the same adp twice. The first time you assign the adp to sDate and the second time you assign the adp to eDate.
When the user click on the 'Set Date" button, the adp is shown, but the result will always be send to the eDate which is currently linked to the adp.

You need to use 2 adp and link adp(0) to sDate and adp(1) the eDate.

B4X:
Sub Globals
    Dim adp(2) As AnotherDatePicker
    .... more code here
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ....
   adp(0).AddToActivity(Activity, VM1.GetView("sDate"))
   .....
   adp(1).AddToActivity(Activity, VM1.GetView("eDate"))
   ....
End Sub

Sub sDate_Click
    adp(0).Show
End Sub

Sub eDate_Click
    adp(1).Show
End Sub
 
Upvote 0

Straker

Active Member
Licensed User
Longtime User
P.S.: on my tablet the Another Date Picker was almost unusable (the numbers were completely on the right side of the panel...)
 
Upvote 0

Straker

Active Member
Licensed User
Longtime User
@Straker can you post a screenshot? Does it also happen with the original AnotherDatePicker?


Sorry for the volume, it takes me some minute to figure out how to take a screenshot on a Android device (now I know something new...)
As you can see the AnotherDatePicker is completely on the left (there are also some numbers missing...)
I just tried the file at the beginning of this thread...


screenshot.png
 
Upvote 0

Straker

Active Member
Licensed User
Longtime User
Mmmm... I tested the same program on another device and it is the same as above. So I think that is something in the program...
 
Upvote 0

sanjibnanda

Active Member
Licensed User
Longtime User
Mmmm... I tested the same program on another device and it is the same as above. So I think that is something in the program...
thanks for taking interest , i am also trying it at my end.
the above problem in the screen shot can be removed if you add
layout Variants as
900x600, scale =1(160dp) and remove the phone Variant
ss.png

regds
 
Last edited:
Upvote 0

sanjibnanda

Active Member
Licensed User
Longtime User
I've downloaded and tested your adpTest.zip
In that source you are using the same adp twice. The first time you assign the adp to sDate and the second time you assign the adp to eDate.
When the user click on the 'Set Date" button, the adp is shown, but the result will always be send to the eDate which is currently linked to the adp.

You need to use 2 adp and link adp(0) to sDate and adp(1) the eDate.

B4X:
Sub Globals
    Dim adp(2) As AnotherDatePicker
    .... more code here
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ....
   adp(0).AddToActivity(Activity, VM1.GetView("sDate"))
   .....
   adp(1).AddToActivity(Activity, VM1.GetView("eDate"))
   ....
End Sub

Sub sDate_Click
    adp(0).Show
End Sub

Sub eDate_Click
    adp(1).Show
End Sub
i have corrected this issue already, but the problem is with to catch the id of VM4.GetView("sDateBtn"&y)

i have now started with the Erel solution of

Dim adp As AnotherDatePicker = SenderLog(adp.Tag)

and will soon do feed back , but i think we should catch the sDateBtn id than adp.tag, so that particular sDateBtn_click show that particular adp.

i have found a work around, and it works..but that's not a good programming

regds
 
Upvote 0

sanjibnanda

Active Member
Licensed User
Longtime User
Sender returns the adp itself. Not the index.

You can add a Tag property to adp to help you distinguish between them:
B4X:
Dim adp As AnotherDatePicker = Sender
Log(adp.Tag)
@Straker can you post a screenshot? Does it also happen with the original AnotherDatePicker?

this code does not work, as there is no tag support to ADP, see the screen shot

error.jpg
 
Upvote 0
Top