Spinner is activated at the start of my activity

I'm trying to use the spinner object in my app, but I'm having trouble, in fact, it is activated at the start of my activity. While I wish it was enabled when was clicked and selected the desired item.

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.ElementaryOperations, android.R.layout.simple_spinner_dropdown_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(adapter);
s1.setOnItemSelectedListener(new OnItemSelectedListener(){
    public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3){

        index1 = s1.getSelectedItemPosition()+1;
        if (index1 == 3){

            finish();
            startActivity(prod);//

        }
    }

    public void onNothingSelected(AdapterView<?> arg0) {}

 });

Answers


spinner listener OnItemSelectedListener is called when you start activity due to get default value.i mean first element and zeroth index. so you can check if position is zero then dont anything.but mind that you cant achieve default selected value.if you put condition for zero.

if cant work proper than see this question


Need Your Help

How do I change the default text font in Eclipse?

eclipse fonts editor default

How do I set the default font size in Eclipse?