Spinner getting selected string

by matio » Sat, 17 Apr 2010 06:16:30 GMT

Sponsored Links
 Hi everyone, I'm trying to expand a todo list program taken from a
tutorial in a magazine. The problem I'm having is getting the value
from a spinner that is selecting the priority of the item, how do I do
it? I think it is something to do with views but how do I get the

Thanks in advance...


Spinner getting selected string

by Bob Kerns » Sat, 17 Apr 2010 10:52:49 GMT

 You have a few options. You can ask the view for the position of the
selected item (getSelectedItemPosition()), or the ID you associated
with that item (getSelectedItemId()), or register listener with

You can get the associated item with getSelectedItem(). You can get
the associated View with getSelectedView(), and you can extract
relevant state from that. You can also register listeners on items
within the view, if they will be changing state as the result of your
interactions with them.

Use whatever is simplest for your application.


Sponsored Links

Other Threads

1. Compass pointing a direction other than North

Hi everyone..I'm trying to implement spomething that I don't even know
if it's possible..

So I have this class which implements a SensorEventListener like
        private SensorEventListener mySensorEventListener = new
                public void onAccuracyChanged(Sensor sensor, int accuracy) {
                public void onSensorChanged(SensorEvent event) {

And a class that handles the way the compass looks like this:

        public static class compassLook extends View {
                private Paint paintPointer = new Paint(Paint.ANTI_ALIAS_FLAG);
                private Paint paintCircle = new Paint(Paint.ANTI_ALIAS_FLAG);
                private Paint paintLeters = new Paint(Paint.ANTI_ALIAS_FLAG);
                private boolean firstDraw;
                private float direction = 0 ;

                public compassLook(Context context) {

                public compassLook(Context context, AttributeSet attrs) {
                super(context, attrs);

                public compassLook(Context context, AttributeSet attrs, int
defStyle) {
                super(context, attrs, defStyle);

                private void init(){
                paintPointer.setColor(Color.argb(255, 209, 114, 2));
                paintCircle.setColor(Color.argb(150, 255, 255, 255));
                paintLeters.setColor(Color.argb(230, 255, 255, 255));
                firstDraw = true;

                protected void onMeasure(int widthMeasureSpec, int
heightMeasureSpec) {

                protected void onDraw(Canvas canvas) {
                int cxCompass = (getMeasuredWidth()/2);
                int cyCompass = (getMeasuredHeight()/2);
                float radiusCompass;
                if(cxCompass > cyCompass){
                 radiusCompass = (float) (cyCompass * 0.9);
                 radiusCompass = (float) (cxCompass * 0.9);
                canvas.drawCircle(cxCompass-50, cyCompass, radiusCompass,


                // Desenho da linha que aponta
                 canvas.drawLine(cxCompass-50, cyCompass,
                   (float)(cxCompass-50 + radiusCompass * Math.sin((double)(-
direction) * 3.14/180)),
                   (float)(cyCompass - radiusCompass * 
* 3.14/180)),
                double mLatitude  =  (mLocation.getLatitude() / 1E6); // I get 
value from a LM request
                double mLongitude =  (mLocation.getLongitude() / 1E6); // I get 
value from a LM request
                double picLatitude = Double.parseDouble(picLatitudeString); // 
I get
this value from a bundle
                double picLongitude = Double.parseDouble(picLongitudeString); 
// I
get this value from a bundle
                float direction = (float) 
mLongitude,  picLatitude-mLatitude));
                        float distancia = (float) (Math.sqrt(Math.pow(mLatitude-
picLatitude, 2) + Math.pow(mLongitude-picLongitude,2)))/2;
                 //Desenho do texto que indica a distancia
                 canvas.drawText(String.valueOf(distancia) + "Km", cxCompass-30,
cyCompass+20, paintLeters);


                public void updateDirection(float dir)
                firstDraw = false;
                direction = dir;


This classes work perfectlly showing me a little circle with a line
pointing the North.

What I would like to do, is ..given this 2 points in space (mLatitude,
mLongitude) and (picLatitude, picLongitude) which are the user
position, and a certain picture position. I'd like the compass to
point to the position of the picture (picLatitude,picLongitude) from
the position they are in the moment (mLatitude,mLongitude)

I came to the trignometry formula that calculates this..being:

float direction = (float) Math.toDegrees(Math.atan2(picLongitude-
mLongitude,  picLatitude-mLatitude));

But when I use it on the updateDirection, the compass line stays
static.. doesn't moves just like it moved when the direction was 0

Do you have any ideia how can I implement this so that the compass is
always pointing the picture position and not the north?

Thank you very much..if you didnt understood what I meant here,
basically I want a line that points me to an Latitude,Longitude
position other than the north itself.


2. How do I customize the parent in an ExpandableListView?

I'm trying to customize the parent(or header) for an expandablelist
and I haven't found a solution yet.
I want an imageview and two textviews in the parent.
This is driving me insane atm. Please help me.



3. ORMLite 3.2 with native Android support for Sqlite released

4. Verizon Moto droid auto update to 2.2 yesterday

5. getting and stopping a single running service

6. How to add option to "share via" menu

7. Fil-rate workaround with FBOs?