我在Android IDK中创建了一个Thread,为什么它表示无效的返回类型!
我想要的只是显示json
Profile
来自Thread thread= new Thread(){
if (getActivity()!=null)
{
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Profile profile = service.getProfile(text);
Gson gson = new Gson();
String json = gson.toJson(profile);
output.setText(json.toString());
}
});
}
};
thread.start();
我想更改片段中的文字
<i><button id="recover-credentials-submit"
ng-class="{disabled: disabled, "btn-primary": true}"
ng-disabled="disabled" type="submit" class="btn btn-primary pull-right">
<span title="send recover email"
aria-hidden="true" class="fa fa-key"></span> Send</button>
</i>
答案 0 :(得分:2)
试试这个
new AsyncTask<Void, Void, Void> (){
private String json;
protected Void doInBackground(Void... voids) {
Profile profile = service.getProfile(text);
Gson gson = new Gson();
json = gson.toJson(profile);
return null;
}
protected void onPostExecute(Void result) {
output.setText(json);
}
}.execute();