简体   繁体   English

不确定我应该在 android 中使用什么控件

[英]Not sure what control in android should I use

Hi I'm new to android and I was hoping to get some minor non-coding help.嗨,我是 android 新手,我希望能得到一些非编码方面的小帮助。 Simply put I am continuously getting an image off from a server, but the problem is I'm not sure which control I should use.简单地说,我不断从服务器获取图像,但问题是我不确定应该使用哪个控件。 I know I can't use async task because it is used as a one time call and I can't use a service because I only want to run it on one activity alone.我知道我不能使用异步任务,因为它被用作一次性调用,我不能使用服务,因为我只想单独在一个活动上运行它。 When the app closed or activity is changed the continuous process stops.当应用程序关闭或活动更改时,连续过程停止。 Should I use thread, executor, future task or some other control?我应该使用线程、执行程序、未来任务还是其他一些控件?

Edit: Basically its going to be just like Async download image except it's going to call continuously while app is still on and the activity is the same as it is.编辑:基本上它就像异步下载图像一样,除了它会在应用程序仍在运行时连续调用并且活动与它相同。 Here is a sample of async download这是异步下载的示例

http://javatechig.com/android/download-image-using-asynctask-in-android http://javatechig.com/android/download-image-using-asynctask-in-android

For image processing you should most often use of of the various image processing libraries out there.对于图像处理,您应该最常使用各种图像处理库。 Check out Picasso and Glide.看看毕加索和滑翔。 They handle all threading and caching automatically for you.它们会自动为您处理所有线程和缓存。

http://square.github.io/picasso/ http://square.github.io/picasso/

https://github.com/bumptech/glide https://github.com/bumptech/glide

Get a image from service is about Android Network Programming .You can use HttpUrlConnection or HttpClient communicate with service,then you use JAVA stuffs, like getting inputStream..Then use BitmapFactory.decodeStream() decode your inputStream and get a image from service.(Remember you must do network operation in child thread:) Then use Handler let your bitmap show in your ImageView!从服务获取图像是关于 Android 网络编程。您可以使用 HttpUrlConnection 或 HttpClient 与服务通信,然后您使用 JAVA 的东西,例如获取 inputStream..然后使用 BitmapFactory.decodeStream() 解码您的 inputStream 并从服务中获取图像。(记住你必须在子线程中进行网络操作:)然后使用Handler让你的位图显示在你的ImageView中! (I don't know if it can help you,forgive my bad English:); (不知道能不能帮到你,原谅我的英文不好:);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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