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

  • Home
  • SEARCH
  • 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 6834725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:08:50+00:00 2026-05-26T23:08:50+00:00

Hello all i have a wheel picker working but at the moment it is

  • 0

Hello all i have a wheel picker working but at the moment it is pulling in numbers from 0-9 for all for wheels. I want to be able to set the values instead of 0-9 I want it to be words which are pulled from a array or string so i can input them myslef as i am not sure where the numbers are being pulled from at the moment. The code is below:

public class PasswActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.passw_layout);
    initWheel(R.id.passw_1);
    initWheel(R.id.passw_2);
    initWheel(R.id.passw_3);
    initWheel(R.id.passw_4);

    Button mix = (Button)findViewById(R.id.btn_mix);
    mix.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mixWheel(R.id.passw_1);
            mixWheel(R.id.passw_2);
            mixWheel(R.id.passw_3);
            mixWheel(R.id.passw_4);
        }
    });


}

// Wheel scrolled flag
private boolean wheelScrolled = false;

// Wheel scrolled listener
OnWheelScrollListener scrolledListener = new OnWheelScrollListener() {
    public void onScrollingStarted(WheelView wheel) {
        wheelScrolled = true;
    }
    public void onScrollingFinished(WheelView wheel) {
        wheelScrolled = false;

    }
};

// Wheel changed listener
private OnWheelChangedListener changedListener = new OnWheelChangedListener() {
    public void onChanged(WheelView wheel, int oldValue, int newValue) {
        if (!wheelScrolled) {

        }
    }
};


/**
 * Initializes wheel
 * @param id the wheel widget Id
 */
private void initWheel(int id) {
    WheelView wheel = getWheel(id);
    wheel.setViewAdapter(new NumericWheelAdapter(this, 0, 9));
    wheel.setCurrentItem((int)(Math.random() * 10));

    wheel.addChangingListener(changedListener);
    wheel.addScrollingListener(scrolledListener);
    wheel.setCyclic(true);
    wheel.setInterpolator(new AnticipateOvershootInterpolator());
}

/**
 * Returns wheel by Id
 * @param id the wheel Id
 * @return the wheel with passed Id
 */
private WheelView getWheel(int id) {
    return (WheelView) findViewById(id);
}

/**
 * Tests entered PIN
 * @param v1
 * @param v2
 * @param v3
 * @param v4
 * @return true 
 */
private boolean testPin(int v1, int v2, int v3, int v4) {
    return testWheelValue(R.id.passw_1, v1) && testWheelValue(R.id.passw_2, v2) &&
        testWheelValue(R.id.passw_3, v3) && testWheelValue(R.id.passw_4, v4);
}

/**
 * Tests wheel value
 * @param id the wheel Id
 * @param value the value to test
 * @return true if wheel value is equal to passed value
 */
private boolean testWheelValue(int id, int value) {
    return getWheel(id).getCurrentItem() == value;
}

/**
 * Mixes wheel
 * @param id the wheel id
 */
private void mixWheel(int id) {
    WheelView wheel = getWheel(id);
    wheel.scroll(-25 + (int)(Math.random() * 50), 2000);
}
}

Any help is appriciated. Thanks

  • 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-26T23:08:51+00:00Added an answer on May 26, 2026 at 11:08 pm

    Could you please refer below wheel demo project, it will very much help related to your problem with string data in wheels .Also code below from same project.

    http://code.google.com/p/android-wheel/

    public class CitiesActivity extends Activity {
        // Scrolling flag
        private boolean scrolling = false;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            setContentView(R.layout.cities_layout);
    
            final WheelView country = (WheelView) findViewById(R.id.country);
            country.setVisibleItems(3);
            country.setViewAdapter(new CountryAdapter(this));
    
            final String cities[][] = new String[][] {
                            new String[] {"New York", "Washington", "Chicago", "Atlanta", "Orlando"},
                            new String[] {"Ottawa", "Vancouver", "Toronto", "Windsor", "Montreal"},
                            new String[] {"Kiev", "Dnipro", "Lviv", "Kharkiv"},
                            new String[] {"Paris", "Bordeaux"},
                            };
    
            final WheelView city = (WheelView) findViewById(R.id.city);
            city.setVisibleItems(5);
    
            country.addChangingListener(new OnWheelChangedListener() {
                            public void onChanged(WheelView wheel, int oldValue, int newValue) {
                                if (!scrolling) {
                                    updateCities(city, cities, newValue);
                                }
                            }
                    });
    
            country.addScrollingListener( new OnWheelScrollListener() {
                public void onScrollingStarted(WheelView wheel) {
                    scrolling = true;
                }
                public void onScrollingFinished(WheelView wheel) {
                    scrolling = false;
                    updateCities(city, cities, country.getCurrentItem());
                }
            });
    
            country.setCurrentItem(1);
        }
    
        /**
         * Updates the city wheel
         */
        private void updateCities(WheelView city, String cities[][], int index) {
            ArrayWheelAdapter<String> adapter =
                new ArrayWheelAdapter<String>(this, cities[index]);
            adapter.setTextSize(18);
            city.setViewAdapter(adapter);
            city.setCurrentItem(cities[index].length / 2);        
        }
    
        /**
         * Adapter for countries
         */
        private class CountryAdapter extends AbstractWheelTextAdapter {
            // Countries names
            private String countries[] =
                new String[] {"USA", "Canada", "Ukraine", "France"};
            // Countries flags
            private int flags[] =
                new int[] {R.drawable.usa, R.drawable.canada, R.drawable.ukraine, R.drawable.france};
    
            /**
             * Constructor
             */
            protected CountryAdapter(Context context) {
                super(context, R.layout.country_layout, NO_RESOURCE);
    
                setItemTextResource(R.id.country_name);
            }
    
            @Override
            public View getItem(int index, View cachedView, ViewGroup parent) {
                View view = super.getItem(index, cachedView, parent);
                ImageView img = (ImageView) view.findViewById(R.id.flag);
                img.setImageResource(flags[index]);
                return view;
            }
    
            @Override
            public int getItemsCount() {
                return countries.length;
            }
    
            @Override
            protected CharSequence getItemText(int index) {
                return countries[index];
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello all i am working on a project in which i have a webpage
Hello all I am working on javascript jquery and svg.I want to ask a
hello all i have my splash screen which i want to show in landscape
Hello all this is my first post here i have been working in an
hello all i want to retrieve my all the wall post that i have
Hello all i have a simple problem i have a alertDialog and i want
Hello All I have used onLongClickListener() to my EditText view but whenever I click
Hello All! I'm active in a fairly large project, but I have limited experience
Hello All, I have a problem regarding Unicode characters . I'm able to append
Hello all I want to make the div's I have inside my td's act

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.