我想在我的android应用程序中使用ksoap2 web服务返回特定的字符串。TextView上的setText异步任务完成
Web服务正在返回正确的值,但设置的文本在任务完成后没有更新。我需要做一些事情(例如试图打开导航抽屉),然后更新它。有任何想法吗??
我的代码如下
// Calling the async class
protected void onResume() {
try {
super.onResume();
new RetrieveTimeWS().execute();
}
catch (Exception e)
{
Log.e("Current Time", e.getMessage());
}
}
以下是异步任务
class RetrieveTimeWS extends AsyncTask<Void, Void, String> {
protected String doInBackground(Void... params) {
String datetime = "";
try {
TextView TVcurrentTime = (TextView) findViewById(R.id.DateTimeNow);
TVcurrentTime.setText("Loading...");
datetime = getDateTimeClass.getDateTime();
TVcurrentTime.setText(datetime);
} catch (Exception e) {
Log.e("Async Task - GetDateTime ", e.getMessage());
}
return datetime;
}
}
的文本字段显示“正在加载...”只等我碰任何部件在屏幕上。如何在Web服务返回文本后将textview更改为所需的字符串。
在此先感谢。
Laks。
在onPostExecute(); http://stackoverflow.com/questions/8369539/android-on-post-execute-in-asynctask – 2015-02-06 13:29:33