IF condition on spinner

Tutorials with advanced 'difficulty' and more Lines of Code.

IF condition on spinner

Postby mazjoe » Mon Jul 02, 2012 5:22 am

i have problem about IF condition...i'm a beginer in android developer

i have this code
Code: Select all
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.ImageView;
import android.widget.Button;

public class spinner extends Activity implements
AdapterView.OnItemSelectedListener {
   String[] arrjenis = {"Gitar akustik", "gitar elektrik", "bass akustik", "bass elektrik"};
    String[] arrmerek = {"ibanez", "yamaha", "fender", "schecter"};
    Button Button01;

   public void onCreate(Bundle icicle) {
      Spinner spin = (Spinner) findViewById(R.id.Spinner01);
      ArrayAdapter aa = new ArrayAdapter(

      Spinner spin1 = (Spinner) findViewById(R.id.Spinner02);
      ArrayAdapter bb = new ArrayAdapter(

      ImageView imageView = (ImageView) findViewById(R.id.imageview1);
      Button01 = (Button)findViewById (R.id.Button01);
      Button01.setOnClickListener( new clicker());

   public void onItemSelected(AdapterView<?> spin, View arg1, int posisi,
         long arg3) {
      // TODO Auto-generated method stub
         case R.id.Spinner01:
            String gitarSelected=arrjenis[posisi];
         case R.id.Spinner02:
            String merkSelected=arrmerek[posisi];
class  clicker implements  Button.OnClickListener
public void onClick(View v) {
if xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

my question :
how to display images
- if spinner01 (arrjenis) is checked "Gitar akustik" and spinner02 (arrmerek) is checked "ibanez" then if button01 pressed, imageView drawing up an acoustic guitar brands ibanez (drawings had been prepared in folder drawable)

other condition

- if spinner01 (arrjenis) is checked "bass elektrik" and spinner02 (arrmerek) is checked "fender" then if button01 pressed, imageView drawing up an electrik bass brands fender (picture had been prepared in folder drawable)


sorry if my english bad 8)
Posts: 2
Joined: Mon Jul 02, 2012 5:06 am


Return to Advanced Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests