0

I set values in my setOnItemSelectedListener depending on what is selected in my spinner.

How can I stop this method being called onCreate?

Thanks in advance

Pragnani
  • 20,075
  • 6
  • 49
  • 74
cwiggo
  • 2,541
  • 9
  • 44
  • 87

1 Answers1

1

Set setOnItemSelectedListener for your spinner not onItemClickListener

Take a boolean field like this

boolean onload=false;

And the in your oncreate

set

 onload=true;

And in your onItemSelectedListener, do like this

spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
     if(!onload)
     {              
     }
onload=false;
    }
    public void onNothingSelected(AdapterView<?> parent) {
    }
});
Pragnani
  • 20,075
  • 6
  • 49
  • 74
  • see edited question, do you understand where i'm coming from? In onItemSelected I set my wattage variable depending on what is selected in the spinner, but I want to be able to load a custom wattage value, so basically I need to skip this setOnItemSelectedListener method – cwiggo May 09 '13 at 12:22
  • @Chris What I need to understand? And where do you coming from? I have provided answer based on your question. do you think this information will be enough to provide answer? – Pragnani May 09 '13 at 12:26
  • see http://stackoverflow.com/questions/16460101/load-data-setonitemselectedlistener for more detail, i'll be deleting this question shortly – cwiggo May 09 '13 at 12:26
  • @Chris Delete this if you can..I'll look at that question – Pragnani May 09 '13 at 12:28
  • thanks, I just cant get my head around it – cwiggo May 09 '13 at 12:30