I think you could implement an addapter for your second spinner so
that an item selected from your first spinner is added to your second
spinner addapte.

On Jun 28, 10:51 am, debai <[email protected]> wrote:
> I am trying to feed onclick item of one spinner to another spinner
>
> Here is the complete code
>
> package com.indusnet;
> import android.app.Activit
> import android.os.Bundle;
> import android.view.View;
> import android.view.View.OnClickListener;
> import android.widget.AdapterView;
> import android.widget.AdapterView.OnItemSelectedListener;
> import android.widget.ArrayAdapter;
> import android.widget.Button;
> import android.widget.EditText;
> import android.widget.Spinner;
> import android.widget.Toast;
>
> public class AddDel extends Activity {
>
>         private Spinner m_myDynamicSpinner;
>         private Spinner m_myDynamicSpinner1;
>         private EditText m_addItemText;
>         private ArrayAdapter<CharSequence> m_adapterForSpinner;
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.edittxtspinner);
>
>         m_myDynamicSpinner =
> (Spinner)findViewById(R.id.Spinner01);
>
>         m_addItemText = (EditText)findViewById(R.id.EditText01);
>
>         Button addButton = (Button)findViewById(R.id.Button01);
>
>         m_adapterForSpinner = new
> ArrayAdapter<CharSequence>(AddDel.this,
> android.R.layout.simple_spinner_item);
>
> m_adapterForSpinner.setDropDownViewResource(android.R.layout.simple_spinner 
> _dropdown_item);
>         m_myDynamicSpinner.setAdapter(m_adapterForSpinner);
>         m_adapterForSpinner.add("dummy item");
>
>         addButton.setOnClickListener(new OnClickListener(){
>
>                         @Override
>                         public void onClick(View v) {
>                                 addNewSpinnerItem();
>                         }
>                         private void addNewSpinnerItem() {
>                                 CharSequence textHolder = "" + 
> m_addItemText.getText();
>                         m_adapterForSpinner.add(textHolder);
>
>                         }
>         });
>         m_myDynamicSpinner1=(Spinner)findViewById(R.id.Spinner02);
>         m_myDynamicSpinner.setOnItemSelectedListener(new
> OnItemSelectedListener() {
>                  @Override
>                  public void onItemSelected(AdapterView<?> arg0, View arg1,
> int position, long id) {
>                  String selectedItemString = (String)
> m_myDynamicSpinner.getSelectedItem();
>
>                  Toast.makeText(AddDel.this,"!"+selectedItemString,
> Toast.LENGTH_LONG).show();
>                  }
>                         @Override
>                         public void onNothingSelected(AdapterView<?> arg0) {
>                                 // TODO Auto-generated method stub
>
>                         }
>                     });
>
>         }
>         public void setM_myDynamicSpinner1(Spinner m_myDynamicSpinner1) {
>                 this.m_myDynamicSpinner1 = m_myDynamicSpinner1;
>         }
>         public Spinner getM_myDynamicSpinner1() {
>                 return m_myDynamicSpinner1;
>         }
>         }
>
> Would appreciate if anybody can give me answer to how to feed the
> other spinner from the clicked item in one.
>
> thanking You
>
> siddhartha

-- 
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