Re: [android-developers] Spinner show on click of button
> > Hi yes I am adding the Button to the view,but i am not adding the spinner > to the view Pretty sure the spinner needs to be added to the view for it to work. One option you can do if you don't want to have the spinner UI is to use AlertDialog.Builder... It allows you to set an array of options to display in a list via setSingleChoiceOptions(). You can then display that by calling show() on the dialog when the button is clicked. I've done that many times when I want the functionality of a spinner but want a different UI for it. Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware On Thu, Jun 21, 2012 at 8:14 AM, vani reddy wrote: > Hi yes I am adding the Button to the view,but i am not adding the spinner > to the view > > > On Thu, Jun 21, 2012 at 7:34 PM, Justin Anderson wrote: > >> spinner.setOnItemSelectedListener(new OnItemSelectedListener() { >>> >>> @Override >>> public void onItemSelected(AdapterView arg0, View arg1, >>> int arg2, long arg3) { >>> // TODO Auto-generated method stub >>> int selectedPosition = spinner.getSelectedItemPosition(); >>> >>> /* >>> * get the category name in which the reason is selected >>> into >>> * the application >>> */ >>> } >>> try it . >>> it wor perfectly >>> >> >> This is not what the OP is asking... This will help for getting the >> selected item once the user has chosen an item. He is asking how to make >> the spinner show the list of options programatically... >> >> >> >> Thanks, >> Justin Anderson >> MagouyaWare Developer >> http://sites.google.com/site/magouyaware >> >> >> On Thu, Jun 21, 2012 at 7:38 AM, Aashish jawla wrote: >> >>> spinner.setOnItemSelectedListener(new OnItemSelectedListener() { >>> >>> @Override >>> public void onItemSelected(AdapterView arg0, View arg1, >>> int arg2, long arg3) { >>> // TODO Auto-generated method stub >>> int selectedPosition = spinner.getSelectedItemPosition(); >>> >>> /* >>> * get the category name in which the reason is selected >>> into >>> * the application >>> */ >>> >>> >>> >>> } >>> >>> try it . >>> it wor perfectly >>> >>> >>> On Thu, Jun 21, 2012 at 5:05 PM, vani reddy >>> wrote: >>> Hi friends, How to open spinner on click of a button. I tried Spinner spinner =new Spinner(this); ArrayAdapter packSizeAdapter = new ArrayAdapter( activity, R.layout.spinner_item, productUOMS); packSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner .setAdapter(packSizeAdapter); Button btn=new Button(this); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { spinner .performClick(); } }); It is not working at all ,Is there anyting i am missing..Please reply -- Regards, Vani Reddy -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en >>> >>> >>> >>> >>> -- >>> - >>> Thanks & Regards >>> Er.Aashish Kumar Jawla >>> (09555865084/09910783591) >>> >>> -- >>> 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+unsubscr...@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 post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > > > -- > Regards, > Vani Reddy > > -- > 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+unsubscr...@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 Go
Re: [android-developers] Spinner show on click of button
Hi yes I am adding the Button to the view,but i am not adding the spinner to the view On Thu, Jun 21, 2012 at 7:34 PM, Justin Anderson wrote: > spinner.setOnItemSelectedListener(new OnItemSelectedListener() { >> >> @Override >> public void onItemSelected(AdapterView arg0, View arg1, >> int arg2, long arg3) { >> // TODO Auto-generated method stub >> int selectedPosition = spinner.getSelectedItemPosition(); >> >> /* >> * get the category name in which the reason is selected >> into >> * the application >> */ >> } >> try it . >> it wor perfectly >> > > This is not what the OP is asking... This will help for getting the > selected item once the user has chosen an item. He is asking how to make > the spinner show the list of options programatically... > > > > Thanks, > Justin Anderson > MagouyaWare Developer > http://sites.google.com/site/magouyaware > > > On Thu, Jun 21, 2012 at 7:38 AM, Aashish jawla wrote: > >> spinner.setOnItemSelectedListener(new OnItemSelectedListener() { >> >> @Override >> public void onItemSelected(AdapterView arg0, View arg1, >> int arg2, long arg3) { >> // TODO Auto-generated method stub >> int selectedPosition = spinner.getSelectedItemPosition(); >> >> /* >> * get the category name in which the reason is selected >> into >> * the application >> */ >> >> >> >> } >> >> try it . >> it wor perfectly >> >> >> On Thu, Jun 21, 2012 at 5:05 PM, vani reddy >> wrote: >> >>> >>> Hi friends, >>> >>> How to open spinner on click of a button. >>> >>> I tried >>> Spinner spinner =new Spinner(this); >>> ArrayAdapter packSizeAdapter = new ArrayAdapter( >>> activity, R.layout.spinner_item, productUOMS); >>> >>> >>> packSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); >>> spinner .setAdapter(packSizeAdapter); >>> >>> >>> Button btn=new Button(this); >>> btn.setOnClickListener(new View.OnClickListener() { >>> @Override >>> public void onClick(View v) { >>> spinner .performClick(); >>> } >>> }); >>> >>> It is not working at all ,Is there anyting i am missing..Please reply >>> >>> -- >>> Regards, >>> Vani Reddy >>> >>> -- >>> 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+unsubscr...@googlegroups.com >>> For more options, visit this group at >>> http://groups.google.com/group/android-developers?hl=en >> >> >> >> >> -- >> - >> Thanks & Regards >> Er.Aashish Kumar Jawla >> (09555865084/09910783591) >> >> -- >> 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+unsubscr...@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 post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Regards, Vani Reddy -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Spinner show on click of button
> > spinner.setOnItemSelectedListener(new OnItemSelectedListener() { > > @Override > public void onItemSelected(AdapterView arg0, View arg1, > int arg2, long arg3) { > // TODO Auto-generated method stub > int selectedPosition = spinner.getSelectedItemPosition(); > > /* > * get the category name in which the reason is selected > into > * the application > */ > } > try it . > it wor perfectly > This is not what the OP is asking... This will help for getting the selected item once the user has chosen an item. He is asking how to make the spinner show the list of options programatically... Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware On Thu, Jun 21, 2012 at 7:38 AM, Aashish jawla wrote: > spinner.setOnItemSelectedListener(new OnItemSelectedListener() { > > @Override > public void onItemSelected(AdapterView arg0, View arg1, > int arg2, long arg3) { > // TODO Auto-generated method stub > int selectedPosition = spinner.getSelectedItemPosition(); > > /* > * get the category name in which the reason is selected > into > * the application > */ > > > > } > > try it . > it wor perfectly > > > On Thu, Jun 21, 2012 at 5:05 PM, vani reddy wrote: > >> >> Hi friends, >> >> How to open spinner on click of a button. >> >> I tried >> Spinner spinner =new Spinner(this); >> ArrayAdapter packSizeAdapter = new ArrayAdapter( >> activity, R.layout.spinner_item, productUOMS); >> >> >> packSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); >> spinner .setAdapter(packSizeAdapter); >> >> >> Button btn=new Button(this); >> btn.setOnClickListener(new View.OnClickListener() { >> @Override >> public void onClick(View v) { >> spinner .performClick(); >> } >> }); >> >> It is not working at all ,Is there anyting i am missing..Please reply >> >> -- >> Regards, >> Vani Reddy >> >> -- >> 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+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > > > -- > - > Thanks & Regards > Er.Aashish Kumar Jawla > (09555865084/09910783591) > > -- > 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+unsubscr...@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 post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Spinner show on click of button
spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub int selectedPosition = spinner.getSelectedItemPosition(); /* * get the category name in which the reason is selected into * the application */ } try it . it wor perfectly On Thu, Jun 21, 2012 at 5:05 PM, vani reddy wrote: > > Hi friends, > > How to open spinner on click of a button. > > I tried > Spinner spinner =new Spinner(this); > ArrayAdapter packSizeAdapter = new ArrayAdapter( > activity, R.layout.spinner_item, productUOMS); > > > packSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); > spinner .setAdapter(packSizeAdapter); > > > Button btn=new Button(this); > btn.setOnClickListener(new View.OnClickListener() { > @Override > public void onClick(View v) { > spinner .performClick(); > } > }); > > It is not working at all ,Is there anyting i am missing..Please reply > > -- > Regards, > Vani Reddy > > -- > 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+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- - Thanks & Regards Er.Aashish Kumar Jawla (09555865084/09910783591) -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Spinner show on click of button
Are you adding your button to your view? Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware On Thu, Jun 21, 2012 at 5:35 AM, vani reddy wrote: > > Hi friends, > > How to open spinner on click of a button. > > I tried > Spinner spinner =new Spinner(this); > ArrayAdapter packSizeAdapter = new ArrayAdapter( > activity, R.layout.spinner_item, productUOMS); > > > packSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); > spinner .setAdapter(packSizeAdapter); > > > Button btn=new Button(this); > btn.setOnClickListener(new View.OnClickListener() { > @Override > public void onClick(View v) { > spinner .performClick(); > } > }); > > It is not working at all ,Is there anyting i am missing..Please reply > > -- > Regards, > Vani Reddy > > -- > 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+unsubscr...@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 post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Spinner show on click of button
Hi friends, How to open spinner on click of a button. I tried Spinner spinner =new Spinner(this); ArrayAdapter packSizeAdapter = new ArrayAdapter( activity, R.layout.spinner_item, productUOMS); packSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner .setAdapter(packSizeAdapter); Button btn=new Button(this); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { spinner .performClick(); } }); It is not working at all ,Is there anyting i am missing..Please reply -- Regards, Vani Reddy -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en