0

I getting default value in EditText even i didn't choose from spinner yet.Can anyone help me?

public void onItemSelected(AdapterView<?> parent, View v, int position,
        long id) {
    // TODO Auto-generated method stub
    etCountry.setText("");
    switch(parent.getId()){
    case R.id.spcountry:
        etCountry.setText(parent.getItemAtPosition(position).toString());
        break;
    }

}
public void onNothingSelected(AdapterView<?> arg0) {
    // TODO Auto-generated method stub
    etCountry.setText("");
}
Yobi Woo
  • 49
  • 7

1 Answers1

0

In you code,

You Setting the edittext value to empty etCountry.setText(""); here. But you setting the value again in Switch case.

Switch Case

   case R.id.spcountry:
    etCountry.setText(parent.getItemAtPosition(position).toString());//Here is where you setting the edittext value again
    //Do you stuff here if you dont want default text
    break;  

EDIT

To find Where you set etCountry value. Go to Find-> or Press Ctl+F. Enter etCountry search it and you will find where you setting the value.

Hope it hepls.

vinothp
  • 9,939
  • 19
  • 61
  • 103