0

まだスピナーから選択していなくても、EditText でデフォルト値を取得しています。

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("");
}
4

1 に答える 1

0

あなたのコードでは、

ここでedittext 値を空に設定しetCountry.setText("");ます。ただし、スイッチの場合は値を再度設定します。

スイッチケース

   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;  

編集

etCountry値を設定した場所を見つけるには。に進みFind-> or Press Ctl+Fます。etCountryと入力して検索すると、値を設定した場所が見つかります。

それが役立つことを願っています。

于 2012-10-18T08:45:40.253 に答える