语境;arrayadapter stateadapter=新的arrayadapter(mainactivity.this,andriod.r.layout.spinner,state);
StateAdapter.setDropDownViewResource(andriod.R.layout.spinner_dropdown_item);
spinner.setAdapter(StateAdapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void OnItemSelected(AdopterView<?> parent, View view, int position, long id) {
String yourState = spinner.getSelectedItem().toString();
if (!yourState.equals("- Choose your state -")) {
spinner.setText("You chose" + yourState);
} else {
txtState.setText("Choose a state");
}
}
public void onNothingSeleced(AdopterView<?> parent) {
}
});
暂无答案!
目前还没有任何答案,快来回答吧!