[android-developers] Re: How to get id of array in spinner

2009-05-12 Thread Daehoon Jeon
I tried but,, it was not working,,,
Someone on the internet said spinner doesn't support setOnItemClickListener(new
OnItemClickListener()
Is it true ? if it's true how do we set OnItemClickListener?

--~--~-~--~~~---~--~~
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] Re: How to get id of array in spinner

2009-05-12 Thread Daehoon Jeon
It had exception error, something wrong with code, but i can't find out.
Is there anyone help me? thank you
private Spinner s;
s = (Spinner) findViewById(R.id.dailylog_type);
ArrayAdapter adapter = ArrayAdapter.createFromResource(
this, R.array.planets_type,
android.R.layout.simple_spinner_item);

 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter);
s.setOnItemSelectedListener(selectListener);

private Spinner.OnItemSelectedListener selectListener = new
OnItemSelectedListener() {
public void onItemSelected(AdapterView parent, View v, int position,
long id) {
 int pos = s.getSelectedItemPosition();
switch (pos) {
case 1:
 Intent i_1 = new Intent(class1.this,class2.class);
 startActivity(i_1);
 break;
case 2:
 Intent i_2 = new Intent(class1.this,class3.class);
 startActivity(i_2);
 break;
}
}
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] Re: How to get id of array in spinner

2009-05-12 Thread Android Users
try setOnItemSelected() method. worked for me..

--~--~-~--~~~---~--~~
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] Re: How to get id of array in spinner

2009-05-12 Thread Android Users
What is the exception you are getting?
You can directly use the position parameter in the onItemSelected rather
than trying to get the position explicitly.

--~--~-~--~~~---~--~~
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] Re: How to get id of array in spinner

2009-05-12 Thread Daehoon Jeon
would you mind show me an simple example about using setOnItemSelected()
method with position parameter?

--~--~-~--~~~---~--~~
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] Re: How to get id of array in spinner

2009-05-12 Thread Android Users
The code you have posted is fine. just instead of
int pos = s.getSelectedItemPosition();

you can use,

int pos = position;

Think that should work.

May be i confused you with the method name in my previous post.[?] i meant
setOnItemSelectedListener(selectListener) only...

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

inline: 330.gif

[android-developers] Re: How to get id of array in spinner

2009-05-12 Thread Daehoon Jeon
Oh,, I just found the problem. I have already change
s.getSelectedItemPosition()
to position... but it still didn't work.
It wasn't a spinner problem. The problem was that the way I called class.
Thank you for help.

--~--~-~--~~~---~--~~
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] Re: How to get id of array in spinner

2009-05-11 Thread Android Users
Add a listener to the spinner..

spinnerObj.setOnItemClickListener(new OnItemClickListener(){

 public void
onItemClick(AdapterViewhttp://developer.android.com/reference/android/widget/AdapterView.html?
parent, View http://developer.android.com/reference/android/view/View.html
view,
int position, long id){

// use the position for your case switches

  }
 });

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