Android Question Know How to count number loop ratingstar

larprogramer

Member
Licensed User
Please help me. i need to count comlum for star seleced and insert to database


B4X:
Sub Globals
    Dim ll As List
    Private Amir_RecyclerView As Amir_RecyclerView
    Private RatingBar1 As RatingBar
    Private lb_QNS As Label
    Private Btn_submit As Button
    Dim number As Int
    Dim check As Boolean = True
    Dim check_text As List
    Private cs As CSBuilder
    Dim Map1 As Map
End Sub

Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("Scss")
    
    
    
    Amir_RecyclerView.Initializer("Amir").GridView(2).Build
    Activity.AddView(Amir_RecyclerView,0dip,13.5%y,100%x,75%y)

    Dim Adapter As Amir_RVAdapter
    Adapter.Initialize("Amir",Adapter.LOOP_NEVER)
    
    Amir_RecyclerView.Adapter=Adapter

    

End Sub
Private Sub Amir_onCreateViewHolder (Parent As Panel,ViewType As Int)
    Parent.LoadLayout("bk_amir")
    Dim bmpBallOn As Bitmap = LoadBitmap(File.DirAssets, "start1.png")
    Dim bmpBallOff As Bitmap = LoadBitmap(File.DirAssets, "star2.png")
    RatingBar1.SetBitmaps(bmpBallOn, Null, bmpBallOff)
    RatingBar1.ForceItemWidth(RatingBar1.Height)
    
End Sub
Private Sub Amir_onBindViewHolder (Parent As Panel,Position As Int)
    Try
        
        RatingBar1.Tag = Position
        lb_QNS.Text = "ABCD " & Position
        
        Parent.Width = 100%x
        Parent.Height=11.5%y
    Catch
        Log(LastException)
    End Try
    

End Sub
Private Sub Amir_GetItemCount As Int
    Return  12 'read_josn.real_json.Size
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub RatingBar1_Changed(NewRating As Float)
    
    Dim ss As RatingBar = Sender
    Dim tag As String = ss.Tag
    'Log(tag & " " & NewRating & " " & "Checked")   
    

    Map1.Initialize
    Map1.Put(tag, NewRating)
Try
    
    Catch
        Log(LastException)
    End Try
    
End Sub


Sub Btn_submit_Click

    
    
End Sub
 

Attachments

Andrew (Digitwell)

Active Member
Licensed User
You should move
map1.initialize out of the _changed event, perhaps put it in Activity_create.

It is resetting the map everytime you add an entry.

There is also no need to convert the tag to a string before using in the map.put, the key to a map can be any object type.

try putting the following code in the submit_click

B4X:
for each ky as string in map1.keys
   log("Key = "&ky &" Value = " & map1.get(ky)
next
 

larprogramer

Member
Licensed User
You should move
map1.initialize out of the _changed event, perhaps put it in Activity_create.

It is resetting the map everytime you add an entry.

There is also no need to convert the tag to a string before using in the map.put, the key to a map can be any object type.

try putting the following code in the submit_click

B4X:
for each ky as string in map1.keys
   log("Key = "&ky &" Value = " & map1.get(ky)
next
Thanks you..;););)
 
Top