onPostExecute()我想显示一些动画加载使用android.But中使用asynctask即时通讯无法显示我期待的动画,更多我无法取消动画以及。 任何人都可以帮助我解决这个问题。无法取消动画加载在android
感谢您的宝贵时间!..
Show_AnimatedLoading.java
ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView=(ImageView) findViewById(R.id.imageView1);
CustomLoad task = new CustomLoad();
task.execute();
}
public class CustomLoad extends AsyncTask
{
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
Show_animation();
}
private void Show_animation() {
// TODO Auto-generated method stub
Animation a = AnimationUtils.loadAnimation(Show_AnimatedLoading.this, R.anim.progress_anim);
a.setDuration(2000);
imageView.startAnimation(a);
a.setInterpolator(new Interpolator()
{
private final int frameCount = 50;
@Override
public float getInterpolation(float input)
{
return (float)Math.floor(input*frameCount)/frameCount;
}
});
}
@Override
protected Void doInBackground(Void... params)
{
// TODO Auto-generated method stub
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
imageView.clearAnimation();
}
}
Progress.xml
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite" />
activity_main.xml中
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000">
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:contentDescription="@string/app_name"
android:src="@drawable/transp_load" />
android:id="@+id/imageView2"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:contentDescription="@string/app_name"
android:src="@drawable/pc_logo_load" />
2014-06-23
prabu
+0
“但是我无法显示其即时通讯期待的动画”,你有什么期待? –
+0
即时通讯设法旋转一个图像 –