在 Activity 的 onCreate() 事件中,我启动了 AsyncTask 以从数据库中检索产品数据。成功完成后,如何更新显示?
元代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.venueviewbasic);
(..)
new GetProductDetails().execute();
class GetProductDetails extends AsyncTask<String, String, String> {
protected String doInBackground(String... params) {
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
// Check for success tag
int success;
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", vid));
(.. retrieve and parse data and set new textview contents ..)
但是,textviews 等不会更新。