Pro6Activity.java
package ps.pro6;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ImageView;
import android.widget.Spinner;
public class Pro6Activity extends Activity implements OnItemSelectedListener {
/**
* www.master-gtu.blogspot.com
* pankaj sharma(8460479175),
* chavda vijay(8460420769)
*/
Spinner spin;
ImageView img;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
spin=(Spinner) findViewById(R.id.spinnernames);
img=(ImageView) findViewById(R.id.imageView1);
spin.setOnItemSelectedListener(this);
}
@Override
public void onItemSelected(AdapterView arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
String name=spin.getSelectedItem().toString();
if(name.equals("AMI"))
img.setImageResource(R.drawable.ami);
else if(name.equals("MEHUL"))
img.setImageResource(R.drawable.mehul);
else if(name.equals("PANKAJ"))
img.setImageResource(R.drawable.pankaj);
else if(name.equals("JIGNESH"))
img.setImageResource(R.drawable.jignesh);
else if(name.equals("VIJAY"))
img.setImageResource(R.drawable.vijay);
else if(name.equals("SATISH"))
img.setImageResource(R.drawable.satish);
}
@Override
public void onNothingSelected(AdapterView arg0) {
// TODO Auto-generated method stub
}
}
No comments:
Post a Comment