animation - Unable to cancel animated loading in onPostExecute() in android -



animation - Unable to cancel animated loading in onPostExecute() in android -

i trying show animation loading using asynctask in android.but im unable show animation im expecting,more on couldn't able cancel animation well. can help me solve issue.

thanks precious time!..

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<void, void, void> { @override protected void onpreexecute() { // todo auto-generated method stub show_animation(); } private void show_animation() { // todo auto-generated method stub animation = 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) { homecoming (float)math.floor(input*framecount)/framecount; } }); } @override protected void doinbackground(void... params) { // todo auto-generated method stub homecoming null; } @override protected void onpostexecute(void result) { // todo auto-generated method stub imageview.clearanimation(); } }

progress.xml

<?xml version="1.0" encoding="utf-8"?> <rotate 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

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000"> <imageview 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" /> <imageview 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" /></relativelayout>

as far see, asynctask doesn't have background operation. "post execute" clear animation starts right after "pre execute" start animation. it's normal don't see anything. seek add together background operation.

try 1 out,

final handler handler = new handler(); // todo // pre execute. new thread(new runnable() { @override public void run() { // todo // background operation. handler.postdelayed(new runnable() { @override public void run() { // todo // post execute. } }, 3000); } }).start();

android animation

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -