public class testAddSpiner extends Activity {
private Spinner m_myDynamicSpinner;
private EditText m_addItemText;
private ArrayAdapter m_adapterForS
addButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
addNewSpinnerItem();
int a= m_adapterForSpinner.getCount();
m_myDynamicSpinner.setSelection(a-1);
// m_adapterForSpinner.notifyDataSetChanged();
}
});
Try to call notifyDataSetChanged() after adding an item to adapter:
private void addNewSpinnerItem() {
CharSequence textHolder = "" + m_addItemText.getText();
m_adapterForSpinner.add(textHolder);
m_adapterForSpinner.notifyDataSetChanged();
}
Have you tried to select the first item? spinner.setSelection(0);
?