usar una vista web reemplazar con la vista de lista?

all, I am developing a app "forum client", I use the webview as each item in listview for showing the post list, there are pics, texts and some attachments which can be downloaded by user. it does work, but the webview is heavy component, need lots of system resources. so I have to find another method to show the post list. I found esta pregunta is the same with my problem, and the last post by author said, use "one webview with bunch of DIVs rendering the individual contents", but I cannot get it, so, what did he mean?

preguntado el 10 de marzo de 12 a las 03:03

1 Respuestas

I think he meant that you should get all the HTML that you are showing in the different WebViews in each ListView item, wrap each in a div tag, then show that in one single WebView that the user can scroll. You should get much better performance since you will only have one WebView on-screen (and thus in memory) at one time, rather than one for each visible row which will take a lot of memory.

respondido 10 mar '12, 08:03

yes, I know that will get the better performance, but I don't know how to fill the div tag by java code, can you give some advice - Mejonzhan

One simple way is to use StringBuilder to create a large HTML string, adding in divs as necessary and otherwise putting your other HTML sources together. A more advanced way would be to build a DOM structure and then convert that to an HTML String. In either case, then you'd call WebView.loadDataWithBaseURL with your HTML String that contains all your divs to finally display it. - Louielouie

Thanks, louieloule, I will try the two methods later. - Mejonzhan

I did it by big StringBuilder, it takes my one week, if I have other time, I will try DOM structure. so let me explain the method as follows: first, you have to know something language, Html, Javascript and css. second, write html code, and insert some flags like <!--{for list}--> that you will replace them with the data by parsing Json, after you replace all of them, you need compose a complete html file, the last, use webview.loadDataWithBaseURL. done. - Mejonzhan

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.