简体   繁体   中英

Possible TextView imeplementation to handle very large data

I have been looking for a while but haven't been able to find an answer. I have a text view in my APK that needs to potentially handle large amounts of text being appended to it a little at a time. So it could grow over time as stuff streams to it. So far I haven't seen any issues and I have let the underlying Android implementation take care of the data. Does anyone know if Android caches these all in memory or that if it passes a watermark level it could then write to file for the TextView? What if it gets too huge, would the APK run out of memory and get killed by Dalvik? If that is the case I am open for any suggestion as how to mitigate this possiblity. One solution in my mind is that have a custom textview that does exactly what I explained and caches data to file if it passes a water mark. However, I am not sure how tricky it would get to detect where the user is navigating within the TextView to pull the data back and forth from the underlying data file and populate the actual TextView object.

Thanks

While I was unable to find the actual threshold, it has been discussed and suggested that extremely long text be displayed in smaller chunks. You can also write to a file which you can then read back in as necessary for your project.

Edit : regarding the TextView bookmark (for lack of a better term), you could always programmatically check to see where the user is in the TextView (checking for a certain character or string at the end of the TextView) and reading the next few lines of text into the TextView. You would have to match the getText().toString() value of the TextView against the readable text in your file.

I'm wondering now too if you would be able to do that in either direction. To save space, you could write your text to file as the user needs it, and update the TextView to only display 5 or 6 lines (arbitrary number). You could trim the TextView in either direction to save memory. You could ellipsize both sides of your text , scroll enable it, and trim/read those points as necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM