Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3675738
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:00:50+00:00 2026-05-19T03:00:50+00:00

I am working in Spinner.. I am having three spinners and i am going

  • 0

I am working in Spinner.. I am having three spinners and i am going to display days (i,e) 1,2,3,4,5…30,31 in 1st spinner and months in 2nd spinner (i,e)1,2,3,…11,12 and Year in 3rd spinner 2010,…. What i want is that that i wanna to display current date,month,year in 1st,2nd,3rd spinner resp when the page loads..from that it is possible to select any day,month,Year
Here is my code::

public class NoteEdit extends Activity implements OnItemSelectedListener {

private EditText mTitleText;
private EditText mBodyText;
private Long mRowId;
private NotesDbAdapter mDbHelper;
private String array_spinner[];
private int currentDayOfMonth=0;
private int currentDayOfDays=0;
private final String[] months = {"1","2","3","4","5","6","7","8","9","10","11","12"};
Spinner s1,s,s2;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDbHelper = new NotesDbAdapter(this);
    mDbHelper.open();
    setContentView(R.layout.note_edit);

     Calendar cal = Calendar.getInstance();
     cal.set(Calendar.MONTH,month);//month starts from 0
     cal.set(Calendar.YEAR,year);
     int noOfDayInMonthyear = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
     Log.v("noOfDayInMonthyear",""+noOfDayInMonthyear);

    ArrayList<Integer> obj=new ArrayList();
    ArrayList<Integer> obj1=new ArrayList();
      for(int i=1;i<=noOfDayInMonthyear;i++){
          obj.add(i); 
      }
      Log.v("Size",""+obj.size());
      for(int i=2010;i<=2020;i++){
          obj1.add(i); 
      }
      Log.v("Size1",""+obj1.size());
         s = (Spinner) findViewById(R.id.Spinner01);
        ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item,obj);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        s.setAdapter(adapter);
        s.setOnItemSelectedListener(NoteEdit.this);

         s1 = (Spinner) findViewById(R.id.Spinner02);
        ArrayAdapter adapter1 = new ArrayAdapter(this,android.R.layout.simple_spinner_item,months);
        adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        s1.setAdapter(adapter1);
        s1.setOnItemSelectedListener(NoteEdit.this);

     s2 = (Spinner) findViewById(R.id.Spinner03);
    ArrayAdapter adapter2 = new ArrayAdapter(this,android.R.layout.simple_spinner_item,obj1);
    adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    s2.setAdapter(adapter2);
    s2.setOnItemSelectedListener(NoteEdit.this);
    s2.setAdapter(adapter2);



    mTitleText = (EditText) findViewById(R.id.title);
    mBodyText = (EditText) findViewById(R.id.body);

    Button confirmButton = (Button) findViewById(R.id.confirm);

    mRowId = savedInstanceState != null ? savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID) 
                                        : null;
    if (mRowId == null) {
        Bundle extras = getIntent().getExtras();            
        mRowId = extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID) 
                                : null;
    }

    populateFields();

    confirmButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            setResult(RESULT_OK);
            finish();
        }

    });
}


public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
        long arg3) {

}


public void onNothingSelected(AdapterView<?> arg0) {


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:00:51+00:00Added an answer on May 19, 2026 at 3:00 am

    if i understand your question right, i think you’re asking how to set the value for each spinner?

    figure out what value you want to select for each spinner and do something like this for each
    http://developer.android.com/reference/android/widget/AbsSpinner.html#setSelection(int, boolean)

     int dateId = <date id in the spinner>;
     s2.setSelection(dateId);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.