android - confusion to pass argument in asyncTask -


In my application, I get an image from the server and those image build animation. All these things have gone in the right way and I have made the method for this. This method is:

  package com. Animation; Import java.io.InputStream; Import java.net.URL; Import android App Import Android.graphics. Bitmap; Import and roid.graphics.BitmapFactory; Import android.graphics.drawable.AnimationDrawable; Import android.graphics.drawable.BitmapDrawable; Import android.graphics.drawable.Drawable; Importroid.os.Bundle; Import android.widget.Button; Import android.widget.ImageView; Public class animation activity {button burrows; Animation drenable animation; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.main); ImageView img = (ImageView) findViewById (R.id.simple_anim); Animation = new animation dracules (); Try {{int i = 0; i <50; i ++} {xyz ("girl000", i); } Animation .setonshot (wrong); } Hold (exception e) {} img.setBackgroundDrawable (animation); Img.post (new starter ()); } Public Zero Xyz (string str, int x) {try {bitmap bitmap = BitmapFactory.decodeStream (new URL) ("http://201.109.115.111/MRESC/images/test/girl/"+"girl000++ X + ".png") .getContent ()); Draw Frame = New BitmapDrawBable (bitmap); Animation.edframe (frame, 50); } Hold (Exception E) {}} Class Starter executes Runnable {public void run () {animation.start (); }}}   

Now that my image is longer than loading the server, so I'm just planning to use asyncTask. But the problem is that I can decide how can I do this? You can give me an example (note: I know asyncTask and already use but the problem is going to be the argument of my xyz () system announcement

Thank you Nik

Here's the code:

  • Note that now the loop is in the background thread
  • After each loop, you publish progress for the installation of the animation frame
  • At the very end, To run A walk on PostExecute

    Please note, this is just a skeleton and coarse sketch, if you have a problem you need to understand and debug. I have not run the code yet

      enhances the public class animation activity (button button; animation overwrite public zero on animation animation; @Create (bundle saved instenstate) {super. (Saved InstantState); setContentView (R.layout.main); Animation = New Animation Drainage (); AsyncTask asyncTask = New AsyncTask () {@Override Protected Zero DoInBackground (Zero ... Parameter) {Try it  // does not block your UI threads (I Execute this whole loop in the background for the int = 0;; i    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -