Android Question Turn off/not send haptic when a particular clv_Click happens

Mark Stuart

Active Member
Licensed User
Longtime User
Hi all,

I have a CustomListView loaded with "records"/rows. One particular row I don't want the haptic sound to happen, but another row (person row) is touched, I want the haptic to happen.
The CLV is loaded with "group headers" - particular rows that designate that the following rows are part of that group header. The group header is a Month and Year. The following rows match the month and year. Think of birthdays and the group header being the Month and Year row and the following rows have birthdays in that month and year.

I don't need a haptic to happen when the group header is touched, but only when the user touches on the person row.
For to touch on a row and have a haptic feedback doesn't make sense when the group header row is display only and doesn't have any function.

Is this possible?

Thanx,
Mark Stuart
 
Solution
I've added my logic to your app, and it works; it only accepts clicks on elements. To do this, I had to change the click color to something more visible. You had the alpha set to 0.

B4X:
Sub LoadBirthdayRecords
    clvPersons.Clear
  
    Dim sCurrentMonthYear As String
    Dim data As DataSet
    Dim rs As ResultSet
  
    rs = oSQL.ExecQuery("SELECT * FROM tblData ORDER BY BirthDate DESC")
  
    Do While rs.NextRow
        data.ID = rs.GetInt("ID")
        data.FirstName = rs.GetString("FirstName")
        data.LastName = rs.GetString("LastName")
        data.BirthDate = rs.GetLong("BirthDate")
      
        Dim sTempMonthYear As String = GetMonthYear(data.BirthDate)
        If sTempMonthYear <> sCurrentMonthYear Then
            'we...

TILogistic

Expert
Licensed User
Longtime User
I was aware of this issue when using a single customlistview, but the simplest solution is to disable the group panel. This prevents the click event from firing on the row where the group is located.
You need to know which row the groups belong to, for example, by adding a flag or disabling the row panel when loading the data.
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I've added my logic to your app, and it works; it only accepts clicks on elements. To do this, I had to change the click color to something more visible. You had the alpha set to 0.

B4X:
Sub LoadBirthdayRecords
    clvPersons.Clear
  
    Dim sCurrentMonthYear As String
    Dim data As DataSet
    Dim rs As ResultSet
  
    rs = oSQL.ExecQuery("SELECT * FROM tblData ORDER BY BirthDate DESC")
  
    Do While rs.NextRow
        data.ID = rs.GetInt("ID")
        data.FirstName = rs.GetString("FirstName")
        data.LastName = rs.GetString("LastName")
        data.BirthDate = rs.GetLong("BirthDate")
      
        Dim sTempMonthYear As String = GetMonthYear(data.BirthDate)
        If sTempMonthYear <> sCurrentMonthYear Then
            'we are passing recID as return value
            clvPersons.Add(CreateGroupHeaderRow(data.BirthDate, clvPersons.AsView.Width), data.ID)
            sCurrentMonthYear = sTempMonthYear
            'we are passing recID as return value
            clvPersons.Add(CreatePersonRow(data, clvPersons.AsView.Width), data.ID)
        Else
            'we are passing recID as return value
            clvPersons.Add(CreatePersonRow(data, clvPersons.AsView.Width), data.ID)
        End If
    Loop
    rs.Close
  
  
    For i = 0 To clvPersons.Size - 1
        Dim p As B4XView = clvPersons.GetPanel(i)
        If p.Tag = "GroupHeader" Then
            p.Parent.Enabled = False
        End If
    Next
  
    'XUIViewsUtils.AddStubToCLVIfNeeded(clvPersons, xui.Color_White)
    clvPersons.ScrollToItem(1)
End Sub

1755237863812.png
 

Attachments

  • Birthday Test.zip
    143.6 KB · Views: 21
Upvote 2
Solution

Mark Stuart

Active Member
Licensed User
Longtime User
I've added my logic to your app, and it works; it only accepts clicks on elements. To do this, I had to change the click color to something more visible. You had the alpha set to 0.

B4X:
Sub LoadBirthdayRecords
    clvPersons.Clear
 
    Dim sCurrentMonthYear As String
    Dim data As DataSet
    Dim rs As ResultSet
 
    rs = oSQL.ExecQuery("SELECT * FROM tblData ORDER BY BirthDate DESC")
 
    Do While rs.NextRow
        data.ID = rs.GetInt("ID")
        data.FirstName = rs.GetString("FirstName")
        data.LastName = rs.GetString("LastName")
        data.BirthDate = rs.GetLong("BirthDate")
    
        Dim sTempMonthYear As String = GetMonthYear(data.BirthDate)
        If sTempMonthYear <> sCurrentMonthYear Then
            'we are passing recID as return value
            clvPersons.Add(CreateGroupHeaderRow(data.BirthDate, clvPersons.AsView.Width), data.ID)
            sCurrentMonthYear = sTempMonthYear
            'we are passing recID as return value
            clvPersons.Add(CreatePersonRow(data, clvPersons.AsView.Width), data.ID)
        Else
            'we are passing recID as return value
            clvPersons.Add(CreatePersonRow(data, clvPersons.AsView.Width), data.ID)
        End If
    Loop
    rs.Close
 
 
    For i = 0 To clvPersons.Size - 1
        Dim p As B4XView = clvPersons.GetPanel(i)
        If p.Tag = "GroupHeader" Then
            p.Parent.Enabled = False
        End If
    Next
 
    'XUIViewsUtils.AddStubToCLVIfNeeded(clvPersons, xui.Color_White)
    clvPersons.ScrollToItem(1)
End Sub

View attachment 166043
Works splendidly! Thank you.
BTW - this line needs to be corrected if you want the app to return to the very top of the CLV:
clvPersons.ScrollToItem(1)

Should be: clvPersons.ScrollToItem(0)
 
Upvote 0
Top