Android ???????????
???????????? ???????[ 2012/10/8 10:41:35 ] ????????
????AsyncTask
????????????′??????????????????
????1??onPreExecute()???÷???????????????????????UI thread???á???????÷????????Щ????????????????????????????????
????2??doInBackground(Params...)??????onPreExecute ??????к???????У??÷???????????????С?????????????????Щ????????????????
???????????publishProgress???????????????????????÷???????????????????????
????3??onProgressUpdate(Progress...)????publishProgress?????????ú?UI thread?????????????????????????????????????????????????????????????
????4??onPostExecute(Result)????doInBackground ???????onPostExecute ????????UI thread?????????????????????÷????????UI thread.
?????????????????1???
????1??Task???????????UI thread?д???
????2??execute??????????UI thread?е???
????3???????????????Щ???????????execute????
????4????task?????????Σ??????ε?????????????
??????????£?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
editText = (EditText) findViewById(R.id.weather_city_edit);
Button button = (Button) findViewById(R.id.goQuery);
button.setOnClickListener(this);
}
public void onClick(View v) {
new GetWeatherTask().execute(“aaa”);
}
class GetWeatherTask extends AsyncTask<String?? Integer?? String> {
protected String doInBackground(String... params) {
return getWetherByCity(params[0]);
}
protected void onPostExecute(String result) {
setTitle(result);
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11