Animationdrawable frame by frame animation by using image view ontouchlistener
Animationdrawable  frame by frame animation by using image view ontouchlistener    

I want to develop shotgun application for that 
    1)first i create animation list in XML that will store res folder 
    2)When i touch image it will play animation and stop for that i use two image views first one touch first image gone next image play animation 
    My problem is first image gone next image come and play animation and also sound 
     i want ones again first image visible when i touch it will play animation like continually
    
    my java code is 
    
    
    ImageView shotgun_img;
        MediaPlayer mp;
    	int flag = 0;
    	ImageView im;
    	Animation animation;
    	AnimationDrawable drawable;
        public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         requestWindowFeature(Window.FEATURE_NO_TITLE);
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
         setContentView(R.layout.shotgun_home);
        
       im = (ImageView) findViewById(R.id.second_img);
         shotgun_img=(ImageView)findViewById(R.id.first_img);
         shotgun_img.setOnTouchListener(new OnTouchListener() {
    			
    			public boolean onTouch(View v, MotionEvent event) {
    				// TODO Auto-generated method stub
    				return false;
    			}
    		});
         shotgun_img.setOnClickListener(new OnClickListener() {
         	
    			public void onClick(View v) {
    				
    			
    				shotgun_img.setVisibility(View.GONE);
    				
    				drawable = (AnimationDrawable) getResources().getDrawable(R.layout.animate);
    		
    				im.setBackgroundDrawable(drawable);
    			    im.post(drawable);
    			    
    				
    			    play();
    			    
                        	   
    				}
    			
    
    	});
       
         
        
     }
     protected void play() {
    		mp = MediaPlayer.create(this, R.raw.hen);
    		mp.seekTo(0);
    		mp.start();
    		mp.setLooping(false);
    	}
    	@Override
    		protected void onPause() {
    		if (this.isFinishing()) { // basically BACK was pressed from this
    			// activity
                mp.stop();
               
    			/*
    			* Toast.makeText(ThundersActivity.this,
    			* "YOU PRESSED BACK FROM YOUR 'HOME/MAIN' ACTIVITY",
    			* Toast.LENGTH_SHORT).show();
    			*/
    			}
    			Context context = getApplicationContext();
    			ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    			List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
    			if (!taskInfo.isEmpty()) {
    			ComponentName topActivity = taskInfo.get(0).topActivity;
    			if (!topActivity.getPackageName().equals(context.getPackageName())) {
    			mp.stop();
    			/*
    			* Toast.makeText(ThundersActivity.this, "YOU LEFT YOUR APP",
    			* Toast.LENGTH_SHORT).show();
    			*/
    			} /*
    			* else { Toast.makeText(ThundersActivity.this,
    			* "YOU SWITCHED ACTIVITIES WITHIN YOUR APP",
    			* Toast.LENGTH_SHORT).show(); }
    			*/
    			}
    			super.onPause();
    }
     xml file 
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
    
        <RelativeLayout
            android:id="@+id/RelativeLayout1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
    
    <ImageView
                android:id="@+id/second_img"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" /> 
    
            <ImageView
                android:id="@+id/first_img"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:scaleType="fitXY"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:src="@drawable/shotgun_01" />
        </RelativeLayout>
    
    animation.xml
    
    <?xml version="1.0" encoding="utf-8"?>
    <animation-list xmlns:android="http://schemas.android.com/apk/res/android"
        
        android:oneshot="true" >
    <!-- <item
            android:drawable="@drawable/shotgun_01"
            android:duration="100"/> -->
        <item
            android:drawable="@drawable/shotgun_02"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/shotgun_03"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/shotgun_04"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/shotgun_05"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/shotgun_06"
            android:duration="100"/>
    
        <!-- <item
            android:drawable="@drawable/c6"
            android:duration="100"/> -->
         <!--  <item
            android:drawable="@drawable/c7"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c8"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c9"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c10"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c11"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c12"
            android:duration="100"/>
         <item
            android:drawable="@drawable/c13"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c14"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c15"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c16"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c17"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c18"
            android:duration="100"/>
          <item
            android:drawable="@drawable/c19"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c20"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c21"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c22"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c23"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c24"
            android:duration="100"/>
        
     <item
            android:drawable="@drawable/c25"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c26"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c27"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c28"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c29"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c30"
            android:duration="100"/>
          <item
            android:drawable="@drawable/c31"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c32"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c33"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c34"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c35"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c36"
            android:duration="100"/> -->
        
    </animation-list>
    
    
    Please help me 
    
    
    
        
Animationdrawable frame by frame animation by using image view ontouchlistener
===

Animationdrawable  frame by frame animation by using image view ontouchlistener    

I want to develop shotgun application for that 
    1)first i create animation list in XML that will store res folder 
    2)When i touch image it will play animation and stop for that i use two image views first one touch first image gone next image play animation 
    My problem is first image gone next image come and play animation and also sound 
     i want ones again first image visible when i touch it will play animation like continually
    
    my java code is 
    
    
    ImageView shotgun_img;
        MediaPlayer mp;
    	int flag = 0;
    	ImageView im;
    	Animation animation;
    	AnimationDrawable drawable;
        public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         requestWindowFeature(Window.FEATURE_NO_TITLE);
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
         setContentView(R.layout.shotgun_home);
        
       im = (ImageView) findViewById(R.id.second_img);
         shotgun_img=(ImageView)findViewById(R.id.first_img);
         shotgun_img.setOnTouchListener(new OnTouchListener() {
    			
    			public boolean onTouch(View v, MotionEvent event) {
    				// TODO Auto-generated method stub
    				return false;
    			}
    		});
         shotgun_img.setOnClickListener(new OnClickListener() {
         	
    			public void onClick(View v) {
    				
    			
    				shotgun_img.setVisibility(View.GONE);
    				
    				drawable = (AnimationDrawable) getResources().getDrawable(R.layout.animate);
    		
    				im.setBackgroundDrawable(drawable);
    			    im.post(drawable);
    			    
    				
    			    play();
    			    
                        	   
    				}
    			
    
    	});
       
         
        
     }
     protected void play() {
    		mp = MediaPlayer.create(this, R.raw.hen);
    		mp.seekTo(0);
    		mp.start();
    		mp.setLooping(false);
    	}
    	@Override
    		protected void onPause() {
    		if (this.isFinishing()) { // basically BACK was pressed from this
    			// activity
                mp.stop();
               
    			/*
    			* Toast.makeText(ThundersActivity.this,
    			* "YOU PRESSED BACK FROM YOUR 'HOME/MAIN' ACTIVITY",
    			* Toast.LENGTH_SHORT).show();
    			*/
    			}
    			Context context = getApplicationContext();
    			ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    			List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
    			if (!taskInfo.isEmpty()) {
    			ComponentName topActivity = taskInfo.get(0).topActivity;
    			if (!topActivity.getPackageName().equals(context.getPackageName())) {
    			mp.stop();
    			/*
    			* Toast.makeText(ThundersActivity.this, "YOU LEFT YOUR APP",
    			* Toast.LENGTH_SHORT).show();
    			*/
    			} /*
    			* else { Toast.makeText(ThundersActivity.this,
    			* "YOU SWITCHED ACTIVITIES WITHIN YOUR APP",
    			* Toast.LENGTH_SHORT).show(); }
    			*/
    			}
    			super.onPause();
    }
     xml file 
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
    
        <RelativeLayout
            android:id="@+id/RelativeLayout1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
    
    <ImageView
                android:id="@+id/second_img"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" /> 
    
            <ImageView
                android:id="@+id/first_img"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:scaleType="fitXY"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:src="@drawable/shotgun_01" />
        </RelativeLayout>
    
    animation.xml
    
    <?xml version="1.0" encoding="utf-8"?>
    <animation-list xmlns:android="http://schemas.android.com/apk/res/android"
        
        android:oneshot="true" >
    <!-- <item
            android:drawable="@drawable/shotgun_01"
            android:duration="100"/> -->
        <item
            android:drawable="@drawable/shotgun_02"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/shotgun_03"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/shotgun_04"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/shotgun_05"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/shotgun_06"
            android:duration="100"/>
    
        <!-- <item
            android:drawable="@drawable/c6"
            android:duration="100"/> -->
         <!--  <item
            android:drawable="@drawable/c7"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c8"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c9"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c10"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c11"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c12"
            android:duration="100"/>
         <item
            android:drawable="@drawable/c13"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c14"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c15"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c16"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c17"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c18"
            android:duration="100"/>
          <item
            android:drawable="@drawable/c19"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c20"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c21"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c22"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c23"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c24"
            android:duration="100"/>
        
     <item
            android:drawable="@drawable/c25"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c26"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c27"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c28"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c29"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c30"
            android:duration="100"/>
          <item
            android:drawable="@drawable/c31"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c32"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c33"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c34"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c35"
            android:duration="100"/>
    
        <item
            android:drawable="@drawable/c36"
            android:duration="100"/> -->
        
    </animation-list>
    
    
    Please help me 
    
    
    
        