-1
如何讓JSONobjects每1.5秒更新多個文本視圖?我不確定JSON對象循環如何在此上下文中工作
? 循環?
根據我的情況我找不到答案。
這裏是我的JSON https://api.wheretheiss.at/v1/satellites/25544
public class IsstatusActivity extends AppCompatActivity {
String longitSt;
JSONParser jsonparser = new JSONParser();
TextView latitude;
TextView longitude;
String lat;
String longit;
JSONObject jobj = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.isstatus);
latitude = (TextView) findViewById(R.id.Coordinates);
new retrievedata().execute();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
return true;
}
class retrievedata extends AsyncTask<String, String, String> {
@Override
public String doInBackground(String... args) {
// TODO Auto-generated method stub
jobj = jsonparser.makeHttpRequest("http://api.wheretheiss.at/v1/satellites/25544");
// check your log for json response
try {
lat = "latitude: " + jobj.getString("latitude");
longit = "longitude :" + jobj.getString("longitude");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return lat;
}
}
protected void onPostExecute(String lat) {
latitude.setText(lat);
longit.setText(longitude);
}
}