Was delayed by this problem for one hours ...
Directly on the solution, refer to the Red section.
Private voidinitviews () {Wheel=(Numberpicker) Findviewbyid (r.id.info_wheel_province); Wheelcity=(Numberpicker) Findviewbyid (r.id.info_wheel_city); Wheelcity.setwrapselectorwheel (false); //read address information JSON Finallist<citybean> Citybeans = Resutils.initcitylist ( This); FinalString[] Pros =Newstring[citybeans.size ()]; for(inti = 0; i < pros.length; i++) {Pros[i]=Citybeans.get (i). Getprovince (); }//wheel.setdescendantfocusability (numberpicker.focus_block_descendants);//wheelcity.setdescendantfocusability (numberpicker.focus_block_descendants);Wheel.setmaxvalue (pros.length-1); Wheel.setminvalue (0); Wheel.setwrapselectorwheel (false); Wheel.setdisplayedvalues (Pros); Wheel.setonvaluechangedlistener (NewNumberpicker.onvaluechangelistener () {@Override Public voidOnvaluechange (Numberpicker picker,intOldval,Final intnewval) {String Citys=Citybeans.get (newval). Getcitys (); Finalstring[] split = Citys.split (",");Wheelcity.setminvalue (0); Wheelcity.setvalue (0); if (Split.length-1 > wheelcity.getmaxvalue ()) {wheelcity.setdisplayedvalues (spli T); Wheelcity.setmaxvalue (split.length -1); } Else {wheelcity.setmaxvalue (split.length -1); Wheelcity.setdisplayedvalues (split); }Wheelcity.setonvaluechangedlistener (NewNumberpicker.onvaluechangelistener () {@Override Public voidOnvaluechange (Numberpicker Picker2,intOldVal2,intNewVal2) {Toast.maketext (infoactivity). This, Pros[newval] + "" +Split[newval2], Toast.length_long). Show (); } }); } }); }
Interested can study the source code to find the reason.
Android Numberpicker array out of the pits