Android Question for next

Almora

Well-Known Member
Licensed User
Longtime User
I could not work to change the article by clicking forward and back. It's only going once. how can I do it.

next button
B4X:
For i = 1 To 3 step 1
Label1.Text=File.ReadString(File.DirAssets, i & ".text")

next

back button
B4X:
For i = 3 To 1 step -1
Label1.Text=File.ReadString(File.DirAssets, i & ".text")

next
 

Attachments

  • test.zip
    8.2 KB · Views: 145

DonManfred

Expert
Licensed User
Longtime User
For what you need a loop if you only want to set the text from one file to the Label?
Your first code will put the
B4X:
"3.text"
into your label
Your second code will put the
B4X:
"1.text"
into your label
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Before getting a code sample you must explain more in detail what exactly you want to do!
I could not work to change the article by clicking forward and back.
What does clicking forward and back mean.
Clicking where on what?
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
When I click on the button, I get the text files in the label.


next(forward) button click =1.txt(label)
next(forward) button click =2.txt(label)
next(forward) button click= 3.txt(label)
.....


back button click =3.txt(label)
back button click =2.txt(label)
back button click= 1.txt(label)
.....
.....
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
I tried a different method.
It works very well.
But he wants long code. Is there a shortcut?

How to do it with for-next?
 

Attachments

  • test2.zip
    8.4 KB · Views: 135
Upvote 0

sorex

Expert
Licensed User
Longtime User
you should work with a counter that you increase or decrease depending on which button is pressed.

if button2 is your next button it could be something like this


B4X:
Sub Button2_Click
if counter <3 then
  counter=counter+1
  label1.Text=File.ReadString(File.DirAssets,counter&".txt")
End If
End Sub
 
Upvote 0
Top