带有webview的Android自定义listview重置url

hi guys i have searching for the solution to this problem... I have a custom listview which is created by extending the baseadapter class and inflating a simple layout which consists of 3 controls 1

  1. Web View
  2. TextView
  3. imageview

And in the webview i will be displaying a small playbutton icon which will play some mp3 from remote.. All that i need to do is reload all the webview controls available in the listview... Hope you could understand what i problem is....

Just Consider this senario.. once the page loads i click on the first webview which will start playing mp3 song and before it if i click on the second webview both the songs will be played at the same time... which is not wat i need. so only possible solution that i think is to reload all the webview in the page everytime the user click the webview...

Hoping for the better reply... Thanks in advance

#0

You should use reload() method to stop playing. To catch event of pressing button inside the WebView you should use either setWebViewClient() or setWebChromeClient() and override the method responsible. I think the last one. More here: http://developer.android.com/reference/android/webkit/WebView.html

#1

Don't reload every WebView, just reload the one you wanna stop playing. You need to keep track of what WebView was accessed first (You'll get the view object from the onClick method), and then when the second one is clicked, load the first url in the first WebView, and start tracking the next. And I think reloading the WebView should be done using the AsyncTask so that it won't stop the UI Thread or it won't interfere with any other process.

Here is a second way, of which I am not so sure. Create an interface between the WebView and your client-side code using Javascript. Then reload the webview once another WebView is clicked. Here is the excerpt from Android page:

Binding JavaScript code to Android code

When developing a web application that's designed specifically for the WebView in your Android application, you can create interfaces between your JavaScript code and client-side Android code...

This is one solution I think, but it isn't the best.

Reference: Here

I still don't understand why you'd use a WebView for your purpose. Why not use an Android UI element, like Button, ImageView,etc, and call the service? It'll save you a lot of workarounds, believe me.

推荐文章

VB6/Best桌面应用语言的本机编译现状

VB6/Best桌面应用语言的本机编译现状

推荐文章

在iPhone应用程序的UITextView中禁用放大镜

在iPhone应用程序的UITextView中禁用放大镜

推荐文章

红黑树-结构

红黑树-结构

推荐文章

tabbar控制器popToRooTViewControler

tabbar控制器popToRooTViewControler

推荐文章

如果我知道HTML表单元格的行和列索引,如何更改该单元格中的属性?

如果我知道HTML表单元格的行和列索引,如何更改该单元格中的属性?

推荐文章

使用PHP发送电子邮件(防止放入垃圾邮件文件夹)

使用PHP发送电子邮件(防止放入垃圾邮件文件夹)

推荐文章

.htaccess twitter或facebook URL命名约定

.htaccess twitter或facebook URL命名约定

推荐文章

Webdev.Webserver已停止工作

Webdev.Webserver已停止工作

推荐文章

列表视图的背景图像仍在单元格文本后面显示白色

列表视图的背景图像仍在单元格文本后面显示白色

推荐文章

Windows Phone 7中的HttpUtility.UrlEncode?

Windows Phone 7中的HttpUtility.UrlEncode?

推荐文章

ActionScript3.0动态加载图像

ActionScript3.0动态加载图像

推荐文章

SQL Server将字符串列值连接为5个字符长

SQL Server将字符串列值连接为5个字符长

推荐文章

用Regex(perl)忽略空白

用Regex(perl)忽略空白

推荐文章

圆形文本框css

圆形文本框css

推荐文章

应用程序级别和请求级别IOC容器存在的测试系统

应用程序级别和请求级别IOC容器存在的测试系统

推荐文章

基于输入检索行

基于输入检索行