M MroBurk Member Licensed User Jan 25, 2022 #1 Dear Gentleman, I need Help with 2 problems: I'd like to understand: 1) How can I declare"For i=0 to infinite" or" i=0 to number of row in a file *.txt"? 2°) How can the code (posted below) works for each row that I create in a customlistview (by "file.txt")? I attached the example's file. I'm blocked... Specifically, I need to understand How can I use "btnsender" with each row? because in this case the btnsender (as string) is the same for each row (the last "stringarray"). thanks for your help... [CODE lang="b4x" title="Lunch Youtube with string"]Private intento As Intent intento.Initialize(intento.ACTION_VIEW,btnsender) intento.SetComponent("com.google.android.youtube/.UrlActivity") StartActivity(intento) end sub[/CODE] Attachments customAnswer.zip customAnswer.zip 12.2 KB · Views: 270
Dear Gentleman, I need Help with 2 problems: I'd like to understand: 1) How can I declare"For i=0 to infinite" or" i=0 to number of row in a file *.txt"? 2°) How can the code (posted below) works for each row that I create in a customlistview (by "file.txt")? I attached the example's file. I'm blocked... Specifically, I need to understand How can I use "btnsender" with each row? because in this case the btnsender (as string) is the same for each row (the last "stringarray"). thanks for your help... [CODE lang="b4x" title="Lunch Youtube with string"]Private intento As Intent intento.Initialize(intento.ACTION_VIEW,btnsender) intento.SetComponent("com.google.android.youtube/.UrlActivity") StartActivity(intento) end sub[/CODE]
Sagenut Expert Licensed User Longtime User Jan 25, 2022 #2 Check this. I didn't put too many comments, sorry. I will be happy to answer your questions (even on the Italian section if you want). I stripped away some parts. Answers to your questions are included into the code. Attachments customAnswer-Sagenut.zip customAnswer-Sagenut.zip 12.2 KB · Views: 274 Upvote 0
Check this. I didn't put too many comments, sorry. I will be happy to answer your questions (even on the Italian section if you want). I stripped away some parts. Answers to your questions are included into the code.
Sagenut Expert Licensed User Longtime User Jan 25, 2022 #4 Feel free to ask whatever it's not clear. In this case: MroBurk said: 1) How can I declare"For i=0 to infinite" or" i=0 to number of row in a file *.txt"? Click to expand... You use a List. To obtain the quantity of items contained in a List you need B4X: List.Size The numeration of items go from 0 to X, so we need B4X: List.Size - 1 to point to the last item starting from 0. MroBurk said: 2°) How can the code (posted below) works for each row that I create in a customlistview (by "file.txt")? Click to expand... In the Button_Click Sub you need to set a new button and assign the Sender to it. This will not create a Copy of the Button but will create a Reference to the clicked one (Sender). Now everything you will read or write on the Reference Button will correspond/happen to the Sender one. This logic work in the same way for every view that you can click in the CustomListView. Upvote 0
Feel free to ask whatever it's not clear. In this case: MroBurk said: 1) How can I declare"For i=0 to infinite" or" i=0 to number of row in a file *.txt"? Click to expand... You use a List. To obtain the quantity of items contained in a List you need B4X: List.Size The numeration of items go from 0 to X, so we need B4X: List.Size - 1 to point to the last item starting from 0. MroBurk said: 2°) How can the code (posted below) works for each row that I create in a customlistview (by "file.txt")? Click to expand... In the Button_Click Sub you need to set a new button and assign the Sender to it. This will not create a Copy of the Button but will create a Reference to the clicked one (Sender). Now everything you will read or write on the Reference Button will correspond/happen to the Sender one. This logic work in the same way for every view that you can click in the CustomListView.
M Mahares Expert Licensed User Longtime User Jan 25, 2022 #5 Nice going @Sagenut. Another easy way is: You make the CLV return value as: stringarray(1) as shown below: Code: CustomListView1.Add(CreateItem2(stringarray(0), stringarray(1),CustomListView1.AsView.Width, 60dip),stringarray(1)) Then you use the Customlistview1 item click as shown below without having to click any buttons . The button tags and the button1 code will not be needed. Code: Private Sub CustomListView1_ItemClick (Index As Int, Value As Object) Dim intento As Intent intento.Initialize(intento.ACTION_VIEW, Value) intento.SetComponent("com.google.android.youtube/.UrlActivity") StartActivity(intento) End Sub Upvote 0
Nice going @Sagenut. Another easy way is: You make the CLV return value as: stringarray(1) as shown below: Code: CustomListView1.Add(CreateItem2(stringarray(0), stringarray(1),CustomListView1.AsView.Width, 60dip),stringarray(1)) Then you use the Customlistview1 item click as shown below without having to click any buttons . The button tags and the button1 code will not be needed. Code: Private Sub CustomListView1_ItemClick (Index As Int, Value As Object) Dim intento As Intent intento.Initialize(intento.ACTION_VIEW, Value) intento.SetComponent("com.google.android.youtube/.UrlActivity") StartActivity(intento) End Sub
Sagenut Expert Licensed User Longtime User Jan 25, 2022 #6 I didn't want to totally transform his code because maybe it was a path to something else. But your addition it's helpful as well. Upvote 0
I didn't want to totally transform his code because maybe it was a path to something else. But your addition it's helpful as well.
M MroBurk Member Licensed User Jan 25, 2022 #7 thanks for the other solution @Mahares. Any Solutions are appreciated!! Upvote 0