如何从onPostExecute内更新TextView [英] How to update a TextView from within onPostExecute
本文介绍了如何从onPostExecute内更新TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这里需要有关onPostExecute的帮助.如果我想将更新放在textView上,那么代码应该是什么,我应该怎么做?.
Need help here, about onPostExecute. If I want to put the update on textView what should be the code and what should I do?.
@Override
protected Value[] doInBackground(Integer... params) {
ApiClient apiClient = new ApiClient(API_KEY);
Variable batteryLevel = apiClient.getVariable(VARIABLE_ID);
Value[] variableValues = batteryLevel.getValues();
return variableValues;
}
@Override
protected void onPostExecute(Value[] variableValues) {
// Update your views here
}
推荐答案
如果要从Ubidots到文本视图获取最后一个值.您可以尝试执行此操作,但是您必须先将Textview设置为OnCreate
If you want get last value from Ubidots to your textview. You can try this, but u must set the textview first OnCreate
@Override
protected void onPostExecute(Value[] variableValues) {
// Update your views here
String status = Double.toString(variableValues[0].getValue());
//this is textview for show last value from ubidots
mBatteryStatus.setText(status);
}
}
这篇关于如何从onPostExecute内更新TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文