If I have a Listview item

Dogbonesix

Active Member
Licensed User
Longtime User
that is a correct URL for some site and I wish to visit that site - how can I click on the listview item and go directly to the the URL?

Probably too easy and everybody else but me has the answer and does it all the time.
 

Dogbonesix

Active Member
Licensed User
Longtime User
Back to ListView

Could not find a way to run a browser and a URL in a ListView_Click. Could be there - just could not find it. Is there any way to run any other application inside of B4A - something like a Shell Command in VB?
 

mikejohnsonharp

Member
Licensed User
Longtime User
Listview to MediaPlayerstream

Check the attached simple project, also, read this to learn more about ListView

Hi NJDude,
I'm new to Basic4Android but your sample listview inspired something I would like to try.
Although, Instead of going from a ListView to web.openbrowser,
I was hoping to stay on the listview page and just play the mp3s as a stream in the background.
I got this far and don't know where to go from here...
Can you help??
Thanks in advance
Mike

Sub Process_Globals
Dim mp As MediaPlayerStream
End Sub
.....
Sub Globals
Dim web As PhoneIntents
Dim ListView1 As ListView
End Sub
......
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")

If FirstTime Then
mp.Initialize("mp")
End If
ListView1.AddTwoLinesAndBitmap2("Free", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-1.mp3")
ListView1.AddTwoLinesAndBitmap2("Chill", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-2.mp3")
ListView1.AddTwoLinesAndBitmap2("Breath", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-3.mp3")
ListView1.AddTwoLinesAndBitmap2("Bridge", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-4.mp3")
ListView1.AddTwoLinesAndBitmap2("Swan", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-5.mp3")
ListView1.AddTwoLinesAndBitmap2("Roar", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-6.mp3")
ListView1.AddTwoLinesAndBitmap2("Forest", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-7.mp3")
ListView1.AddTwoLinesAndBitmap2("Labyrinth", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-8.mp3")

End Sub
........
Sub Listview1_ItemClick (Position As Int, Value As MediaPlayerStream)
mp.Load

'THIS IS WHERE I"M STUCK AS FAR AS CALLING THE STREAMER FROM THE LISTVIEW

End Sub
..........
Sub mp_StreamReady
Log("starts playing")
mp.Play
End Sub
......
Sub mp_StreamError (ErrorCode As String, ExtraData As Int)
Log("Error: " & ErrorCode & ", " & ExtraData)
ToastMessageShow("Error: " & ErrorCode & ", " & ExtraData, True)
End Sub
.....
Sub mp_StreamBuffer(Percentage As Int)
Log(Percentage)
End Sub
 

Dogbonesix

Active Member
Licensed User
Longtime User
URL in ListView Works

NJDude,

I have several Listview samples and I thought the attached was the same I already had. Your sample works like a charm.

Now that the URL works I would like to expand on the question Mike... proposed. In VB6 one can use a shell Command to run an application and pass parameters to same. With the Shell Command I can Run winword and the a file and within the VB6 app I can select a ListView item that will Run winword that in turns the file. Which (kinda) address's Mike...'s problem but one would know when a file is open or closed. I think that can be done in VB6 but I have not successfully accomplished same - although there the media player that might work.

Do you know of a way to mimic the Shell Command or maybe something better?

Thanks,
 

NJDude

Expert
Licensed User
Longtime User
@mikejohnsonharp

Ok, look at the attached project, it will play the mp3 when you tap on the ListView item.

Also, next time, it would be better if you attached your project instead of posting the code, it makes it easy to work things out ;)

To do that, on the IDE click on File -> Export as ZIP
 

Attachments

  • StreamingSample.zip
    10.3 KB · Views: 269
Last edited:

NJDude

Expert
Licensed User
Longtime User
NJDude,

I have several Listview samples and I thought the attached was the same I already had. Your sample works like a charm.

Now that the URL works I would like to expand on the question Mike... proposed. In VB6 one can use a shell Command to run an application and pass parameters to same. With the Shell Command I can Run winword and the a file and within the VB6 app I can select a ListView item that will Run winword that in turns the file. Which (kinda) address's Mike...'s problem but one would know when a file is open or closed. I think that can be done in VB6 but I have not successfully accomplished same - although there the media player that might work.

Do you know of a way to mimic the Shell Command or maybe something better?

Thanks,

In B4A there's no "shell" command to open apps (actually there is but at the command prompt level to work directly with Android/Linux), the command you're referring to, to open apps and docs are called INTENTS, there are tons of samples posted in the forums, if you need help with one specific one, then just ask, I'll be happy to help you out.
 
Top