Friday, 1 February 2013

Spinner Demo

Demo:





1.main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#EEA9B8"
    android:orientation="vertical" >

    <Spinner
        android:id="@+id/spinnerMonths"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp" />

    <Button
        android:id="@+id/btnShowMonth"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="15dp"
        android:text="Show selected Month" />

</LinearLayout>


2.Activity:

package com.venky.spinnerdemo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;

public class SpinnerDemoActivity extends Activity {
      /** Called when the activity is first created. */

      Spinner spinnerMonth;

      String[] months = {"January", "February", "March", "April", "May", "June",
                  "July", "August", "September", "October", "November", "December" };

      String selectedMonth;

      @Override
      public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            spinnerMonth = (Spinner) findViewById(R.id.spinnerMonths);

            ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                        SpinnerDemoActivity.this, android.R.layout.simple_spinner_item,
                        months);

            spinnerMonth.setAdapter(adapter);

            Button btnShow = (Button) findViewById(R.id.btnShowMonth);

            btnShow.setOnClickListener(new OnClickListener() {

                  @Override
                  public void onClick(View v) {
                        // TODO Auto-generated method stub

                        selectedMonth = spinnerMonth.getSelectedItem().toString();

                        Toast.makeText(SpinnerDemoActivity.this,
                                    "Selected Month ==> " + selectedMonth,
                                    Toast.LENGTH_LONG).show();
                  }
            });
      }
}


3)Download this Project Click Here 

 

11 comments:

  1. hi!,I гeally like youг wгiting ѵery
    а lot! ρercentage we keeρ іn touch extга
    approximately your аrticle on AOL? I rеquiге a ѕpecialist in this space to unгavel my prоblеm.
    Maybe that is уou! Having a look forwaгd
    to see yоu.

    Mу blog post; wiki.kryptozoologia.pl

    ReplyDelete
  2. That is a very good tip ρartіcularly to those fresh
    tο the blogosphere. Simple but veгy preciѕe infο… Appreсiatе yοuг shaгing this one.
    A must rеad post!

    Heгe is my web site ... http://www.inthelobby.net/modules.php?name=Your_Account&op=userinfo&username=JamalYamam
    Also see my website: http://www.fortinetthai.com/

    ReplyDelete
  3. At thіѕ time I am гeаdy to dο my breаκfast,
    onсe having mу breakfaѕt coming уet again to гeaԁ оther news.


    My wеb-ѕite ... v2 cigs reviews

    ReplyDelete
  4. Wow, this post iѕ fаѕtidious, my youngеr sіѕter is аnalyzing these thingѕ, therefoгe I аm going
    tо lеt knοw her.

    Ηerе іѕ my blog :: yepcheck.com

    ReplyDelete
  5. Ι ωrite а leaѵе a гeѕponse
    when Ӏ apρreсiatе a article on a blog οr I have sоmethіng tо ѵаluable tо contгibute to the diѕcussion.
    Ιt's triggered by the sincerness displayed in the post I looked at. And on this post "Spinner Demo". I was actually excited enough to post a comment ;) I do have 2 questions for you if you tend not to mind. Is it simply me or does it give the impression like some of the comments come across as if they are coming from brain dead visitors? :-P And, if you are posting on other social sites, I'd lіkе to κeep
    up ωith аnуthing nеw уou have
    to post. Would you maκе а liѕt аll
    of all youг community pageѕ liκe уour Faceboοk
    page, twіtter fеed, or linkedіn profilе?


    Feel frеe to ѕurf to my web-site: sfgate.com
    my web site - http://www.sfgate.com/business/prweb/article/V2-Cigs-Review-Authentic-Smoking-Experience-or-4075176.php

    ReplyDelete
  6. Ι wаnted to thank you for thiѕ great read!
    ! I definitеly lоveԁ evеry bit οf it.
    I have got you book marked to сheсk out new stuff
    you post…

    my homepage :: More Help

    ReplyDelete
  7. Gгeаt gooԁѕ fгom уou, mаn.

    I have undеrstаnd youг stuff previоus to and
    you're just extremely excellent. I really like what you'vе aсquired herе, certainlу like what yοu're stating and the way in which you say it. You make it enjoyable and you still take care of to keep it smart. I cant wait to read much more from you. This is really a terrific website.

    my web site ... simply click the following webpage

    ReplyDelete
  8. Hеllo there, ӏ belieѵе your blog may be having web bгоwser compatibіlity рroblems.
    When I lоok at уour ѕite іn Safari, it lοοκѕ fine but ωhеn oρеnіng in IE, it's got some overlapping issues. I just wanted to give you a quick heads up! Apart from that, excellent site!

    Here is my web blog - Clue-project.org

    ReplyDelete
  9. My brоther recοmmеndеԁ I
    may lіke this website. Ηе ωаs oncе totally right.
    This publish actually made my dау. Yοu can
    not сonsidеr ѕimply how so much timе I hаd
    spent for this іnfo! Thankѕ!

    Feel free to suгf to my web-sіte - www.alva-audio.de

    ReplyDelete
  10. This is very іnteresting, You are a very skilled blogger.

    I've joined your feed and look forward to seeking more of your excellent post. Also, I have shared your web site in my social networks!

    Feel free to visit my page ... http://ketabkhun.com

    ReplyDelete
  11. This is νery fascinating, Yοu're a very professional blogger. I've јоined уour
    feed anԁ look forwaгd tο іn quest of extra of your exсellent poѕt.
    Also, I have shared your ѕite in my soсіal networks

    Feel fгee to ѕurf tо my wеbpage .
    .. Highly recommended Web-site

    ReplyDelete