我想知道,如果我可以在所选项目发生变化时为MaterialBetterSpinner设置事件监听器吗?
类似的东西:
String [] TIPLIST = "Elektro","Oprema","Vodovod","Ogrevanje","Internet","Požarne naprave","Drugo"};
ArrayAdapter<String> arrayAdapterTip = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line,TIPLIST);
MaterialBetterSpinner tipSpinner = (MaterialBetterSpinner)findViewById(spinnerTipNapake);
tipSpinner.setAdapter(arrayAdapterTip);
tipSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
//MaterialBetterSpinner changed
}
但似乎MaterialBetterSpinner没有setOnItemSelectedListener。
答案 0 :(得分:2)
MaterialBetterSpinner没有setOnItemSelectedListener。 相反,你可以使用它:
tipSpinner.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
spinnerValue=tipSpinner.getText().toString();
Log.i("value", spinnerValue);
}
});