Android Question Hidden buttons in HSV are clickable

Sergio83

Active Member
Licensed User
Longtime User
Hello everybody,

I am facing a problem regarding the use of an horizontal scroll view in which I create programmaticaly a serie of buttons. For information, there are more buttons than the scroll view can show at a time (that's the interest of this HSV!).

The problem is when I click out of the scroll view area the hidden buttons remain clickable.

Is that normal or did I make a mistake?

If needed I can post the involved part of my code.

Thank's by advance to help me if possible

Best regards
 

lemonisdead

Well-Known Member
Licensed User
Longtime User
It seems to be normal : not visible doesn't mean disabled as I understand it
 
Upvote 0

Sergio83

Active Member
Licensed User
Longtime User
Hi Lemonisdead,

In a general way I agree with you. But, in this specific case the buttons are clickable outside the HSV area (don't confuse betwheen "not showed" vs "not visible" ...).

It is like if the items of a VSV which are not showed could be clickable outside the VSV area !

You see what I mean?

Regards
 
Upvote 0

Sergio83

Active Member
Licensed User
Longtime User
Hi Klaus,

As you've suggested me I wrote a small project with just the extraction of the part which is not working in my app and, guess what?

It works OK !!!!!

I have to dig deeper this issue it is probably relating to something else in my layout or code.

I will let you know ...

Anyway, thank's for your help!

Regards
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
As you've suggested me I wrote a small project with just the extraction of the part which is not working in my app and, guess what?
It works OK !!!!!
I suspected that there was a problem somewhere in your code.
Are you sure that you add the buttons onto the internal panel of the horizontal scrollviiew.
 
Upvote 0

Sergio83

Active Member
Licensed User
Longtime User
Yes I do:

Global declaration statements
B4X:
' Boutons fonction scrollable
   Private hsv_actions As HorizontalScrollView
   Private BtnNb As Int       : BtnNb = 7
   Private lib_btn_scrl(7) As String : lib_btn_scrl=Array As String("ECLAI","CHAUF","ARROS","CCTV","METEO","WEBR","DOWNLOAD")
   Private bgnd_btn(7) As String :bgnd_btn=Array As String("eclairage.png","chauffage.png","arrosage.png","cctv.png","meteo50.png","webradio50.png","download.png")
   Private pnl_btn_width As Int   : pnl_btn_width = 50dip   
   Private btn_fonc As Button

Procedural statements for buttons creation
B4X:
For i = 0 To BtnNb - 1
     Dim pnl As Panel
     
     pnl.Initialize("")
     hsv_actions.Panel.AddView(pnl, 3dip + i * pnl_btn_width,0, pnl_btn_width, 100%y)
     pnl.LoadLayout("btn_action")
     Dim btn As Button
     btn = pnl.GetView(0)
     btn.SetBackgroundImage(LoadBitmap(File.DirAssets,bgnd_btn(i)))
     btn.Tag=lib_btn_scrl(i)
   Next
   hsv_actions.Panel.width = BtnNb*pnl_btn_width+10dip

Procedural statements for buttons click
B4X:
Sub btn_fonc_Click
   Dim btn As Button
   Dim row As String
   
   btn = Sender
   row = btn.Tag
   
   Select row
 
Upvote 0

Sergio83

Active Member
Licensed User
Longtime User
Hi again Klaus,

Night is good counselor!

In fact I have found that if only a part of a button is displayed in a HSV the entire area of the button is clickable.
In my case it happens that the next button after the last one that is fully displayed was partially displayed (only the left margin) but the image of its background is not displayed (that's why I did not understand what was happening).

I've just to adjust the length of the HSV and now everything is OK!

Thank's again for your help Klaus

Regards

Everybody has to consider that this thread is closed.
 
Upvote 0
Top