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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:15:06+00:00 2026-06-05T07:15:06+00:00

I am developing an application based on Android 2.1, on one page of my

  • 0

I am developing an application based on Android 2.1, on one page of my application, there needs an numberpicker. we know that android 2.1 doesn’t contain numberpicker control, so I write one.

I need to show my version of numberpicker on Android 2.1, but the ICS style numberpicker in Android 4.0, to achieve that aim, I used reflection, When in my code, I detected the current Build.VERSION.SDK_INT >= 14, I reflect a numberpicker of the target platform, and add it to current view dynamically.

My question is I can reflect a numberpicker when I run my application on an Android 4.0 platform, but the numberpicker style doesnot appear to be ICS style, Why?

thanks in advance!

  • 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-06-05T07:15:07+00:00Added an answer on June 5, 2026 at 7:15 am

    If you have the patience you could probably back-port the NumberPicker class. That aside, why use reflection? If you set your target API to 15 this is all you need. In your layout folder declare your alternative number picker. In layout-v11 (NumberPicker is available in API 11 Honeycomb or higher) declare android.widget.NumberPicker. Give each the same ID and in your Activity have something along these lines:

    private NumberPicker mNumPicker;
    private SomeView mOldNumPicker;
    
    public void onCreate(...) {
        // Use NumberPicker
        if (android.os.Build.VERSION.SDK_INT >= 11) {
            mNumPicker = findViewById(R.id.numpicker);
        } else {
            mOldNumPicker = findViewById(R.id.numpicker);
        }
    }
    

    This was you do not need reflection and will not run into any crashes due to accessing non-existent APIs. From here on out you just check if (mNumPicker == null) and if (mOldNumPicker == null) and determine which methods to call based on that. There is also this example of a Number Picker using Buttons and an EditText.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a android tab based application, i need to know how to replace
I am developing an Android application that uses a WebView pointed at a jQueryMobile-based
I'm developing a small android mobile application with a tab based interface. One tab
I am developing an android application based on pdf reader so i got opensource
I am currently developing a little sketching application based on HTML5 Canvas element. There
I'm developing an application that detects Source-based games running on the LAN. Following up
I am developing an quiz based application. I wanted to know like, how can
Good evening. I'm developing an android application that uses Facebook SDK. I've no problem
I'm developing my first Android application and it is based partly on displaying some
i am developing one application which is based on SIP. And i want to

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.