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 7494521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:36:08+00:00 2026-05-29T17:36:08+00:00

How can I create a date picker for just months and years? For example

  • 0

How can I create a date picker for just months and years?

For example I want a picker with just

2012,2013 as year
and 4,5,6,7 as months.

Thank you

  • 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-29T17:36:10+00:00Added an answer on May 29, 2026 at 5:36 pm

    You can make your own like soo… I know this one has days as well but you get the point..

    Its composed of two views for each picker, representing buttons, with a ImageView in the center, and a textSwitcher that takes care of the numbers.

    enter image description here

    public class EditHomeworkActivity extends Activity implements ViewSwitcher.ViewFactory{
    
    private TextSwitcher mSwitcher1;
    private TextSwitcher mSwitcher2;
    private TextSwitcher mSwitcher3;
    
    public static int hwID;
    public static int change = 0;
    public static int year = 1819710;
    public static int day = 1819710;
    public static int month = 1819710;
    
    
    int prevMnth;
    
    Calendar cal;
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    
        setContentView(R.layout.edit_homework_dialog);
    
        mSwitcher1 = (TextSwitcher) findViewById(R.id.day);
        mSwitcher1.setFactory(this);
    
        mSwitcher2 = (TextSwitcher) findViewById(R.id.month);
        mSwitcher2.setFactory(this);
    
        mSwitcher3 = (TextSwitcher) findViewById(R.id.year);
        mSwitcher3.setFactory(this);
    
        Animation in = AnimationUtils.loadAnimation(this,
                android.R.anim.fade_in);
        Animation out = AnimationUtils.loadAnimation(this,
                android.R.anim.fade_out);
    
        mSwitcher1.setInAnimation(in);
        mSwitcher1.setOutAnimation(out);
    
        mSwitcher2.setInAnimation(in);
        mSwitcher2.setOutAnimation(out);
    
        mSwitcher3.setInAnimation(in);
        mSwitcher3.setOutAnimation(out);
    
        Button confirm= (Button) findViewById(R.id.confirm);
        Button cancel = (Button) findViewById(R.id.cancel );
    
        cal = Calendar.getInstance();
    
        if(year != 1819710){cal.set(Calendar.YEAR, year);}
        if(month != 1819710){cal.set(Calendar.MONTH, month);}
        if(day != 1819710){cal.set(Calendar.DAY_OF_MONTH, day);}
    
        ImageButton dayP= (ImageButton) findViewById(R.id.dayP);
        ImageButton dayM= (ImageButton) findViewById(R.id.dayM);
    
        ImageButton monthP= (ImageButton) findViewById(R.id.monthP);
        ImageButton monthM= (ImageButton) findViewById(R.id.monthM);
    
        ImageButton yearP= (ImageButton) findViewById(R.id.yearP);
        ImageButton yearM= (ImageButton) findViewById(R.id.yearM);
    
    
        // add a click listener to the button
        confirm.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
    
                EditHomeworkActivity.DueYear = cal.get(Calendar.YEAR);
                EditHomeworkActivity.DueMonth = cal.get(Calendar.MONTH);
                EditHomeworkActivity.DueDay = cal.get(Calendar.DAY_OF_MONTH);
    
                finish();
            }
        });
    
        cancel.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                finish();
            }
        });
    
        dayP.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {cal.roll(Calendar.DAY_OF_YEAR, 1);update();}});
        dayM.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {cal.roll(Calendar.DAY_OF_YEAR, -1);update();}});
    
        monthP.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {cal.roll(Calendar.MONTH,  1);update();}});
        monthM.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {cal.roll(Calendar.MONTH, -1);update();}});
    
        yearP.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {cal.roll(Calendar.YEAR,  1);update();}});
        yearM.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {cal.roll(Calendar.YEAR, -1);update();}});
    
    
        update();
    }
    
    
    
    public void update(){
    
        mSwitcher1.setText(String.valueOf(cal.get(Calendar.DAY_OF_MONTH)));
        mSwitcher2.setText(sort(cal.get(Calendar.MONTH)));
        mSwitcher3.setText(String.valueOf(cal.get(Calendar.YEAR)));
    
    
    }
    
    private CharSequence sort(int i) {
    
        String retrn = null;
    
        if(i == 0){retrn = "Jan";prevMnth = i;}
        if(i == 1){retrn = "Feb";}
        if(i == 2){retrn = "Mar";}
        if(i == 3){retrn = "Apr";}
        if(i == 4){retrn = "May";}
        if(i == 5){retrn = "Jun";}
        if(i == 6){retrn = "Jul";}
        if(i == 7){retrn = "Aug";}
        if(i == 8){retrn = "Sept";}
        if(i == 9){retrn = "Oct";}
        if(i == 10){retrn = "Nov";}
        if(i == 11){retrn = "Dec";prevMnth = i;}
    
        if(i == 12){if(prevMnth == 0){cal.roll(Calendar.MONTH, -1);}else{cal.roll(Calendar.MONTH, 1);}update();}
    
        return retrn;
    }
    
    public View makeView() {
        TextView t = new TextView(this);
        t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
        t.setTextSize(36);
    
        return t;
    }
    
    
    
    
    }
    

    <?xml version="1.0" encoding="utf-8"?>
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/relativeLayout1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@drawable/android_rel_background" >
    
            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:padding="15dip"
                android:text="Homework Due Date:"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#00B7EE" />
    
            <View
                android:id="@+id/v"
                android:layout_width="match_parent"
                android:layout_height="4dip"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/title"
                android:background="#DFDFDF" />
    
            <TextView
                android:id="@+id/dateText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/v"
                android:layout_centerHorizontal="true"
                android:padding="15dip"
                android:text="Date:"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#00B7EE"
                android:visibility="gone" />
    
            <View
                android:id="@+id/v1"
                android:layout_width="match_parent"
                android:layout_height="0dip"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/dateText"
                android:background="#DFDFDF" />
    
            <RelativeLayout
                android:id="@+id/rel1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" android:layout_below="@+id/v1" android:padding="15dip">
    
                <RelativeLayout
                    android:id="@+id/rel1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:layout_centerInParent="true">
    
                    <View
                        android:id="@+id/v1"
                        android:layout_width="1dip"
                        android:layout_height="wrap_content"
                        android:layout_alignBottom="@+id/dayV"
                        android:layout_alignTop="@+id/dayV"
                        android:background="#DFDFDF" />
    
                    <LinearLayout
                        android:id="@+id/dayV"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentTop="true"
                        android:orientation="vertical" android:layout_toRightOf="@+id/v1">
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
    
                        <ImageButton
                            android:id="@+id/dayP"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/android_rel_background"
                            android:padding="30dip"
                            android:src="@drawable/plus" />
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
    
                        <RelativeLayout
                            android:id="@+id/relativeLayout2"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" >
    
                            <TextSwitcher
                                android:id="@+id/day"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:paddingBottom="15dip"
                                android:paddingTop="15dip" android:layout_centerInParent="true">
                            </TextSwitcher>
    
                        </RelativeLayout>
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
    
                        <ImageButton
                            android:id="@+id/dayM"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/android_rel_background"
                            android:padding="30dip"
                            android:src="@drawable/minus" />
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
                    </LinearLayout>
    
                    <View
                        android:id="@+id/v2"
                        android:layout_width="1dip"
                        android:layout_height="wrap_content"
                        android:layout_alignBottom="@+id/dayV"
                        android:layout_alignTop="@+id/dayV"
                        android:layout_toRightOf="@+id/dayV"
                        android:background="#DFDFDF" />
    
                    <LinearLayout
                        android:id="@+id/monthV"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentTop="true"
                        android:layout_toRightOf="@+id/v2"
                        android:orientation="vertical" >
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
    
                        <ImageButton
                            android:id="@+id/monthP"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/android_rel_background"
                            android:padding="30dip"
                            android:src="@drawable/plus" />
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
    
                        <RelativeLayout
                            android:id="@+id/relativeLayout3"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" >
    
                            <TextSwitcher
                                android:id="@+id/month"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:paddingBottom="15dip"
                                android:paddingTop="15dip" android:layout_centerInParent="true">
                            </TextSwitcher>
    
                        </RelativeLayout>
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
    
                        <ImageButton
                            android:id="@+id/monthM"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/android_rel_background"
                            android:padding="30dip"
                            android:src="@drawable/minus" />
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
                    </LinearLayout>
    
                    <View
                        android:id="@+id/v3"
                        android:layout_width="1dip"
                        android:layout_height="wrap_content"
                        android:layout_alignBottom="@+id/dayV"
                        android:layout_alignTop="@+id/dayV"
                        android:layout_toRightOf="@+id/monthV"
                        android:background="#DFDFDF" />
    
                    <LinearLayout
                        android:id="@+id/yearV"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentTop="true"
                        android:layout_toRightOf="@+id/v3"
                        android:orientation="vertical" >
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
    
                        <ImageButton
                            android:id="@+id/yearP"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/android_rel_background"
                            android:src="@drawable/plus" android:paddingLeft="40dip" android:paddingRight="40dip" android:paddingBottom="30dip" android:paddingTop="30dip"/>
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
    
                        <RelativeLayout
                            android:id="@+id/relativeLayout4"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" >
    
                            <TextSwitcher
                                android:id="@+id/year"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:paddingBottom="15dip"
                                android:paddingTop="15dip" android:layout_centerInParent="true">
                            </TextSwitcher>
    
                        </RelativeLayout>
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
    
                        <ImageButton
                            android:id="@+id/yearM"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/android_rel_background"
                            android:src="@drawable/minus" android:paddingLeft="40dip" android:paddingRight="40dip" android:paddingTop="30dip" android:paddingBottom="30dip"/>
    
                        <View
                            android:id="@+id/v"
                            android:layout_width="match_parent"
                            android:layout_height="1dip"
                            android:layout_alignParentLeft="true"
                            android:layout_below="@+id/title"
                            android:background="#DFDFDF" />
                    </LinearLayout>
    
                    <View
                        android:id="@+id/v4"
                        android:layout_width="1dip"
                        android:layout_height="wrap_content"
                        android:layout_alignBottom="@+id/dayV"
                        android:layout_alignTop="@+id/dayV"
                        android:layout_toRightOf="@+id/yearV"
                        android:background="#DFDFDF" />
                </RelativeLayout>
    
            </RelativeLayout>
    
            <View
                android:id="@+id/v2"
                android:layout_width="match_parent"
                android:layout_height="1dip"
                android:layout_alignParentLeft="true"
                android:background="#DFDFDF" android:layout_below="@+id/rel1"/>
    
            <LinearLayout
                android:id="@+id/linearLayout1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/v2"
                android:background="#FF909090"
                android:paddingBottom="5dip" >
    
                <Button
                    android:id="@+id/confirm"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="4dip"
                    android:layout_weight="1"
                    android:padding="5dip"
                    android:text="Confirm" />
    
                <Button
                    android:id="@+id/cancel"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="4dip"
                    android:layout_weight="1"
                    android:padding="5dip"
                    android:text="Cancel" />
            </LinearLayout>
    
        </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a Settings-Widget, where I can choose a Date. Because it
can we create a runtime Date Picker Dialog from a non activity class in
In javascript you can create a Date object from a string, like var mydate
How can I create a date object which is less than n number of
We can't use java.text.SimpleDateFormat, so is there any way to create date object from
I'm trying to create a strongly type html helper extension for a date picker
How can I change the selected date of jquery Date picker dynamically on the
I want to set format of date to dd-mm-yyyy for control date time picker,i
I can get the created date, file size etc for a file using the
I can create a menu item in the Windows Explorer context menu by adding

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.