Friday, December 20, 2013

[android-developers] onitemclicklistener connected with 2 spinners

Dears i will need your suppot as i am tring to create 2 Spinners and i tried to connect between those spinners by them content items using onitemclicklistener my plan is
when i choese item in first spinner and write number in text view then selected item from second spinner it gives answer in the second text view i would like to share with you the codes i use it :


public class te extends Activity implements OnItemSelectedListener  {
    // needed extend activity to allow it to go throw that
   
   
   
   Spinner Spte1;
   String[] path1 ={"Celsius", "Kelvin","Farenheit"};
  

   Spinner Spte2;
   String[] path2 ={"Celsius","Kelvin","
Farenheit"};

   EditText ETTE1;
   EditText ETTE2;
   
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.temperature);
            ETTE1 = (EditText) findViewById(R.id.ette1);
            ETTE2 = (EditText) findViewById(R.id.ette2);
            //need to connect it with xml file named ma2
           
           
            ArrayAdapter<String> adabter =new ArrayAdapter<String>(te.this, android.R.layout.simple_spinner_item,path1);
            Spte1 = (Spinner)findViewById(R.id.spte1);
            Spte1.setAdapter(adabter);
           
            ArrayAdapter<String> adabter2 =new ArrayAdapter<String>(te.this, android.R.layout.simple_spinner_item,path2);
            Spte2 = (Spinner)findViewById(R.id.spte2);
            Spte2.setAdapter(adabter2);
           
    }


        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
            int position1 = Spte1.getSelectedItemPosition();
            switch (position1){
           
            case 0:


                break;
               
            case 1:
               
                break;
            case 2:
               
                break ;
                }
        }

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


appreciate your support guys and sorry for my bad English .

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate