Note that there are some explanatory texts on larger screens.

plurals
  1. POAnimation doesn't start even after calling from outside onCreate
    primarykey
    data
    text
    <p>I would like to do frame-by-frame animation in my android activity. I went through the developer guide and found that the start() method has to be called from outside the onCreate() method to get the animation started. I used the similar onTouchEvent() method to start the animation. But the animation is not started. While searching, I found the following post( <a href="https://stackoverflow.com/questions/2785336/starting-frame-by-frame-animation/9694289#9694289">Starting Frame-By-Frame Animation</a> ) where it has been mentioned that animation could be started from onClick() method(But code was not provided). I am not able to do that. Could someone help me solve this problem?</p> <p>One more important point I want to add is, I am able to call start() of Mediaplayer object from the onTouchEvent method and not the start() of animation.</p> <p>I have one more question. I am using emulator 2.3.3. Is animation supported in SDK 2.3.3?</p> <p>I am posting my code here:</p> <pre><code>public class firstface extends Activity { MediaPlayer mp1; AnimationDrawable anim; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mp1 = MediaPlayer.create(this, R.raw.red); status = ReadStatus(); ImageView image = (ImageView)findViewById(R.id.image_1); image.setBackgroundResource(R.drawable.anim_1); anim = (AnimationDrawable) image.getBackground(); /*image.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mp1.start(); anim.start(); } });*/ Button but_1_2 = (Button) findViewById(R.id.button_1_2); but_1_2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub to_be_writ = my_face + ":l:" + down + ":d:n"; WriteStatus(to_be_writ); intent = "android.intent.action." + right + "FACE"; startActivity(new Intent(intent)); } }); } public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { mp1.start(); anim.start(); return true; } return super.onTouchEvent(event); } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); mp1.release(); } @Override protected void onStop() { // TODO Auto-generated method stub super.onStop(); mp1.release(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload