我正在尝试使用 2 NumberPickers 创建一个对话框。我希望它们是默认的 Holo 主题样式。我找不到任何好的例子。到目前为止,我得到了:
LayoutInflater inflater = (LayoutInflater)
getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View npView = inflater.inflate(R.layout.number_picker_dialog, null);
NumberPicker minPicker = (NumberPicker) npView.findViewById(R.id.min_picker);
minPicker.setMaxValue(100);
minPicker.setMinValue(0);
NumberPicker maxPicker = (NumberPicker) npView.findViewById(R.id.max_picker);
maxPicker.setMaxValue(100);
maxPicker.setMinValue(0);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Text Size:");
builder.setView(npView);
builder.setPositiveButton("Okay",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
builder.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
dialog = builder.create();
dialog.show();
number_picker_dialog xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:holo="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<NumberPicker
android:id="@+id/min_picker"
android:width="100dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:/>
<NumberPicker
android:id="@+id/max_picker"
android:width="100dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
但是颜色选择器文本是白色的(像背景一样),我无法设置 NumberPicker 的 textColor。
我该如何设置 textColor 或者有人知道一个好的 NumberPicker 示例吗?