LinearLayout hlayout=createHLayout();
        LinearLayout.LayoutParams wcfp = new
LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
        TextView label = new TextView(this);
        label.setLayoutParams(wcfp);
        label.setText(label1);
        hlayout.addView(label);

        Spinner dynamicSpinner = new Spinner(this);
        Log.v("","spinnerId "+spinnerId);
        dynamicSpinner.setId(spinnerId);
        dynamicSpinner.setName(label.getText().toString());

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line,itemoption);
        adapter.setDropDownViewResource(R.layout.custom_dropdown_txt);
        dynamicSpinner.setAdapter(adapter);
        LinearLayout.LayoutParams wsfp = new
LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);



        dynamicSpinner.setLayoutParams(wsfp);
        dynamicSpinner.setPadding(10,0,0,0);
        /////////////
        hlayout.addView(dynamicSpinner);
        dynamicSpinner.setOnItemSelectedListener(listener);


above code will generate spinners dynamically,
when we will click on any spinner then that method will call.


OnItemSelectedListener listener=new OnItemSelectedListener(){
            @Override
        public void onItemSelected(AdapterView<?> arg0, View view, int
position,long arg3) {
            // TODO Auto-generated method stub

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }

    };

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to