Android Question Using an ImageSlider to Display a List of Images and their Corresponding Names

Mahares

Expert
Licensed User
Longtime User
I put a 9 country flags in a list and used an imageslider to move forward and backward to display each flag. I have a label under the slider that displays the name of the image. The label shows the proper image name for one complete cycle of scrolling through the images, but afterwards the label gets stuck with the wrong image name. Can someone please determine how I can get it to display the label text to match the visible image each time. Complete project is zipped and attached: Thank you

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    lblFlag.Color=Colors.DarkGray
    MyList.Initialize
    MyList2.Initialize
    MyList=File.ListFiles(File.DirAssets)
    For Each f As String In MyList
        If f.EndsWith(".png") Then
            MyList2.Add(f)
        End If
    Next
    ImageSlider1.WindowBase.Color=Colors.Cyan
    ImageSlider1.NumberOfImages = MyList2.Size
    If FirstTime Then
        timer1.Initialize("timer1", 2500)
    End If
    ImageSlider1.PrevImage
End Sub

Sub ImageSlider1_GetImage (Index As Int) As ResumableSub
    Idx=Index
    Return xui.LoadBitmapResize(File.DirAssets,MyList2.Get(Index), _
    ImageSlider1.WindowBase.Width/2, ImageSlider1.WindowBase.Height, True)  
End Sub

Sub btnNext_Click
    ImageSlider1.NextImage
    lblFlag.Text=MyList2.Get(Idx) & "   " & Idx
End Sub

Sub btnPrev_Click
    ImageSlider1.PrevImage
    lblFlag.Text=MyList2.Get(Idx) & "   " & Idx
End Sub

Sub btnPlay_Click
    timer1.Enabled = Not(timer1.Enabled)
    If timer1.Enabled Then btnPlay.Text = Chr(0xF04D) Else btnPlay.Text = Chr(0xF04B)
End Sub

Sub Timer1_Tick
    btnNext_Click
End Sub
 

Attachments

  • ImageSliderCountryFlagsForForum.zip
    68.6 KB · Views: 186
Top