[android-developers] Spinner Help

2012-05-20 Thread Ashintha Rukmal
Hi,, I'm new to android developing...
I'm developing a simple app that have 5 spinners.. when I select 1
item in a spinner I want to auto select other spinner items that
equals to the selected item position.
I used "setOnItemSelectedListner" and it worked for the 1st spinner..
but others don't work. here's my code for 1st 2 spinners. any
solution?


spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView parentView, View
selectedItemView, int position, long id) {
int pos1=spinner1.getSelectedItemPosition();
spinner2.setSelection(pos1);
spinner3.setSelection(pos1);
spinner4.setSelection(pos1);
spinner5.setSelection(pos1);
 }

 public void onNothingSelected(AdapterView arg0) {
 }
});

spinner2.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView parentView, View
selectedItemView, int position, long id) {
int pos2=spinner2.getSelectedItemPosition();
spinner1.setSelection(pos2);
spinner3.setSelection(pos2);
spinner4.setSelection(pos2);
spinner5.setSelection(pos2);
}

public void onNothingSelected(AdapterView arg0) {
}
});

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

2012-05-21 Thread Ashintha Rukmal
Hi,,
I'm new to android developing.. I'm trying to make a simple app that
contains 5 spinners. When I select one item in a spinner I want to
auto select other spinner items that equals to selected item position.
I used setOnItemSelected listner and it worked for the 1st spinner.
But when I select item in another spinner nothing will happen..
here's my code for 1st two spinners. Any solution


spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView parentView, View
selectedItemView, int position, long id) {
int pos1=spinner.getSelectedItemPosition();
spinner1.setSelection(pos1);
spinner2.setSelection(pos1);
spinner3.setSelection(pos1);
spinner4.setSelection(pos1);
}

public void onNothingSelected(AdapterView arg0) {
}
});

spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView parentView, View
selectedItemView, int position, long id) {
int pos2=spinner.getSelectedItemPosition();
spinner.setSelection(pos2);
spinner2.setSelection(pos2);
spinner3.setSelection(pos2);
spinner4.setSelection(pos2);
}

public void onNothingSelected(AdapterView arg0) {
}
});

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

2012-05-21 Thread Justin Anderson
>
> int pos2=spinner.getSelectedItemPosition();
>

Shouldn't this line be the following?
*int pos2 = spinner1.getSelectedItemPosition();*

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Mon, May 21, 2012 at 9:47 AM, Ashintha Rukmal  wrote:

> int pos2=spinner.getSelectedItemPosition();
>

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

2012-05-23 Thread TreKing
On Sun, May 20, 2012 at 12:39 AM, Ashintha Rukmal wrote:

> I used "setOnItemSelectedListner" and it worked for the 1st spinner.. but
> others don't work. here's my code for 1st 2 spinners. any solution?
>

Debug your app. At the very least, explain what "other don't work" means
and give us all the information you've discovered for yourself while trying
to solve your problem.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

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

2012-05-31 Thread Narendra Singh Rathore
Use the following

spinner1.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected(AdapterView parentView, View
selectedItemView, int position, long id)
{

spinner2.setSelection(position);
spinner3.setSelection(position);
spinner4.setSelection(position);
spinner5.setSelection(position);
  }

public void onNothingSelected(AdapterView arg0)
{
}
});

spinner2.setOnItemSelectedListener(new OnItemSelectedListener() {
   public void onItemSelected(AdapterView parentView, View
selectedItemView, int position, long id) {

>
>spinner1.setSelection(position);
>spinner3.setSelection(position);
>spinner4.setSelection(position);
>spinner5.setSelection(position);
>}
>
>public void onNothingSelected(AdapterView arg0) {
>}


The position, I put as argument to setSelection method is the position of
selected item.

Hope this will help you.

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