Android Question Remove click sound

Slacker

Active Member
Licensed User
Longtime User
Hello Folks,
Is this possible to remove click sound when is raised an event for a specific button or a panel ?

Thank you !
 

Slacker

Active Member
Licensed User
Longtime User
Works very fine Thank you boss
 
Upvote 0

IanMc

Well-Known Member
Licensed User
Longtime User
This works very well and is it easy to loop through for a set of buttons?

I have a bunch of buttons, 16 of which are sound effect buttons labeled Sfx1 through Sfx16 for these buttons I have also set the Tag properties 1 through 16

Can I change this:
B4X:
Dim jo As JavaObject = Sfx1
jo.RunMethod("setSoundEffectsEnabled", ArrayAsObject(false))
into a loop to disable the click sound for all 16 Sfx buttons?

Would I have to declare all 16 buttons as globals? (Dim them) it's no biggie if I have to do that.

I tried this but I think I'm a little off base:
B4X:
Dim jo As JavaObject
For i = 0 To Activity.NumberOfViews - 1
  If Activity.GetView(i) Is Button Then
     Dim b As Button
     b = Activity.GetView(i)
     If b.Tag > 0 AND b.Tag < 17 Then
        Log("doing button no." & b.Tag)
        jo = b
        jo.RunMethod("setSoundEffectsEnabled", Array As Object(False))
     End If
  End If
Next

I also tried with b = Sender but that didn't work either.
 
Upvote 0

IanMc

Well-Known Member
Licensed User
Longtime User
This is all interesting learning as being able to iterate through views saves lots of code and makes the code more readable.

Your solution above will stop all of the buttons from making the click noise but if I try to limit the selection to the buttons that have the tag property set 1 through 16 I get a big red java error

It says:
java.lang.NumberFormatException: Invalid double: ""

I was playing about with this code:
B4X:
    For Each v As View In Activity.GetAllViewsRecursive
        If v Is Button Then 'AND v.Tag > 0 AND v.Tag < 17 Then
        Log(v.Tag)
        Dim d As Double = v.Tag
            If d > 0 AND d < 17 Then
              Dim jo As JavaObject = v
                jo.RunMethod("setSoundEffectsEnabled", Array As Object(False))
            End If
        End If
    Next
as you can see I first tried with the line
B4X:
If v Is Button AND v.Tag > 0 AND v.Tag < 17 Then
then I commented a bit of that out then I tried first putting the value of v.Tag into an Int and then into a Double but I still get the Java error.

If I don't try to limit the selection then it works fine
 
Last edited:
Upvote 0

IanMc

Well-Known Member
Licensed User
Longtime User
That did it! Thanks Erel!
B4X:
    For Each v As View In Activity.GetAllViewsRecursive
        If v Is Button AND IsNumber(v.Tag) AND v.Tag > 0 AND v.Tag < 17 Then
            Dim jo As JavaObject = v
            jo.RunMethod("setSoundEffectsEnabled", Array As Object(False))
        End If
    Next
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…