我想要更改numberpicker的向上,向下按钮
...我尝试了numberpicker.getchildat();
但它返回null
XML
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="10"
android:gravity="center">
<NumberPicker
android:id="@+id/mypage_hoursetting_np"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="@null"/>
</LinearLayout>
的java
mypage_hoursetting_np = (NumberPicker)view.findViewById(R.id.mypage_hoursetting_np);
mypage_minutesetting_np = (NumberPicker)view.findViewById(R.id.mypage_minutesetting_np);
...
public void setNumberpicker(){
View hour_upbutton = mypage_hoursetting_np.getChildAt(0);
View hour_text = mypage_hoursetting_np.getChildAt(1); // null
View hour_downbutton = mypage_hoursetting_np.getChildAt(2); // null
View minute_upbutton = mypage_minutesetting_np.getChildAt(0);
View minute_text = mypage_minutesetting_np.getChildAt(1); // null
View minute_downView = mypage_minutesetting_np.getChildAt(2); // null
mypage_hoursetting_np.setMaxValue(12);
mypage_hoursetting_np.setMinValue(1);
mypage_hoursetting_np.setWrapSelectorWheel(true);
mypage_minutesetting_np.setMaxValue(60);
mypage_minutesetting_np.setMinValue(1);
mypage_minutesetting_np.setWrapSelectorWheel(true);
Drawable alarmup_image = new BitmapDrawable(getActivity().getResources(), ImageDecoder.decodeSampledBitmapFromResource(getActivity().getResources(), R.drawable.mypage_alarmset_up_image, 200, 200));
Drawable alarmdown_image = new BitmapDrawable(getActivity().getResources(), ImageDecoder.decodeSampledBitmapFromResource(getActivity().getResources(), R.drawable.mypage_alarmset_down_image, 200, 200));
hour_upbutton.setBackground(alarmup_image);
//hour_downbutton.setBackground(alarmdown_image);
minute_upbutton.setBackground(alarmup_image);
//minute_downView.setBackground(alarmdown_image);
}
如何更改numberpicker up,down background? 请帮帮我:(