简体   繁体   中英

how to render view in android based on the data received from server?

I am new to android development. I am trying to build basic shopping cart. I want to know how can I render view based on the data (product details) received from server. Because I will make a call to server in AsyncTask and I will have to wait for the data and then only I will be able to render them. So, I couldn't be able to figure out how would I manage it? Any help is appreciated.

Use a broadcastreceiver in the activity that contains the view you want to render. Look at this answer:

How to send data to another app which is not started

Render your view in the onReceive() function of your BroadcastReceiver.

正如您将要使用AsyncTask ,您可以在onPostExecute()方法中呈现所需的任何视图,该方法在UIThread上运行。

在执行AsyncTask之前,我将显示一个进度条,然后在AsyncTask的onPostExecute()方法中隐藏该进度条,并使用请求的数据更新视图。

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