loleana
loleana

Reputation: 37

number picker crash the application

Q1:Is it possible to use a number picker for data ?

I just tried to do by next code to set string values in the Number Picker but when i roll the picker to see the next value the application crash here is the code:

String[] manga={"death note","runway","blood bro"};

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        NumberPicker pic=(NumberPicker) findViewById(R.id.numberPicker1);
        pic.setMaxValue(manga.length);
        pic.setMinValue(0);
        pic.setWrapSelectorWheel(false);
        pic.setDisplayedValues(manga);

    }

Upvotes: 0

Views: 849

Answers (1)

user1404380
user1404380

Reputation: 40

pic.setMaxValue(manga.length-1);

Upvotes: 2

Related Questions