Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Thursday, 18 October 2012

Create an application that will have spinner with list of animation names. On selecting animation name , that animation should affect on the images displayed below.

Pro10Activity.java
package ps.pro10;

import android.app.Activity; 
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ImageView;
import android.widget.Spinner;

public class Pro10Activity extends Activity implements OnItemSelectedListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 Spinner spin;
 ImageView imgmaster;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        spin=(Spinner) findViewById(R.id.spinnereffect);
        imgmaster=(ImageView) findViewById(R.id.imageViewmaster);
        
        spin.setOnItemSelectedListener(this); 
    }

 @Override
 public void onItemSelected(AdapterView arg0, View arg1, int arg2,
   long arg3) {
  // TODO Auto-generated method stub
  Animation anim=AnimationUtils.loadAnimation(this, R.anim.alpha);
  if(spin.getSelectedItem().equals("alpha"))
   anim=AnimationUtils.loadAnimation(this, R.anim.alpha);
  else if(spin.getSelectedItem().equals("Rotate"))
   anim=AnimationUtils.loadAnimation(this, R.anim.rotate);
  else if(spin.getSelectedItem().equals("Scale"))
   anim=AnimationUtils.loadAnimation(this, R.anim.scale);
  else if(spin.getSelectedItem().equals("Translate"))
   anim=AnimationUtils.loadAnimation(this, R.anim.translate);
  
  imgmaster.startAnimation(anim);
 }

 @Override
 public void onNothingSelected(AdapterView arg0) {
  // TODO Auto-generated method stub
  
 }
}

1 comment: