目录
一、项目内容
使用AsyncTask设计一个异步任务:异步进度条加载,后显示加载图片。
开发环境:Android Studio、Android SDK 11.0
二、使用步骤
1.自定义MyAsyncTask类继承AsyncTask
2.定义AsyncTask的三种泛型参数
3.重写方法相关方法
4.调用execute方法执行异步任务
三、代码实现
1.项目结构
2.主要样式 activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">