I am working on a project in which I need to dynamically add \[code\]TextView\[/code\] and \[code\]Spinner\[/code\] as well from the program. I was able to add these two things dynamically from my program successfully. I am doing all these things in the \[code\]AsyncTask\[/code\] meaning in the background.\[code\]@Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.matching); LinearLayout layout = (LinearLayout ) findViewById(R.id.llayout); RequestTask rt = new RequestTask(getBaseContext(), layout); rt.execute("URL");}class RequestTask extends AsyncTask<String, String, String> { private Context cont; private LinearLayout layout; public RequestTask(Context context, LinearLayout layout) { this.cont = context; this.layout = layout; } @Override protected String doInBackground(String... uri) { ... } @Override protected void onPostExecute(String result) { super.onPostExecute(result); ... for (Map.Entry<String, String> entry : mapColumns.entrySet()) { //setting spinner and textview here } //And at the endI am setting my Button Button button = new Button(cont); button.setWidth(100); button.setText("Save"); layout.addView(button); //Not sure whether I need this here or not. addListenerOnButton(); } public void addListenerOnButton() { int count = layout.getChildCount(); View v = null; for(int i=0; i<count; i++) { v = layout.getChildAt(i); } }\[/code\]Problem Statement:-Now what I need to do is- As soon as I click on the \[code\]Save Button\[/code\], it should grab all the items that I have selected in my \[code\]spinner\[/code\] and print it out on the console.Problem that I am facing is- I am not sure first of all how to get the Items that I have selected in \[code\]Spinner\[/code\] using the \[code\]layout\[/code\] and then print it out as soon as I click on the \[code\]Save Button\[/code\]. If I was grabbing the spinner items through string.xml file then I would have done this problem but I am setting it dynamically so that is the reason I am facing problem.Can anyone help me out here?NOTE:- In my above example, I will be having \[code\]10 TextView\[/code\] and \[code\]10 Spinner\[/code\] and at the end one \[code\]Save Button\[/code\].