Select the items in Spinner dynamically through code

view story

http://stackoverflow.com – I am working on a project in which I need to dynamically add TextView and Spinner as well. I was able to add these two things dynamically from my program. Now when I was trying to select some items in the Spinner, it was not selecting those items. Does I need to do anything to make that item selected in Spinner? for (Map.Entry<String, String> entry : mapColumns.entrySet()) { spinnerArray = new ArrayList<String>(); final TextView rowTextView = new TextView(cont); final Spinner spinner = new Spinner(cont); rowTextView.setLayoutParams(new LayoutParams(LayoutParam (HowTos)