在Android的选取器对话框中更改项目的文本颜色,可以通过自定义样式来实现。以下是一种实现方式:
<style name="CustomDialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="android:textColorPrimary">@color/custom_text_color</item>
</style>
在上述代码中,我们定义了一个名为CustomDialogTheme的样式,并将android:textColorPrimary属性设置为自定义的文本颜色。
<color name="custom_text_color">#FF0000</color>
在上述代码中,我们定义了一个名为custom_text_color的颜色,值为红色(#FF0000)。
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.CustomDialogTheme);
builder.setTitle("选择项目")
.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// 处理点击事件
}
})
.show();
在上述代码中,我们通过AlertDialog.Builder的构造函数将样式设置为CustomDialogTheme。
这样,选取器对话框中的项目文本颜色就会被更改为自定义的颜色。
推荐的腾讯云相关产品:腾讯云移动推送(https://cloud.tencent.com/product/tpns)
领取专属 10元无门槛券
手把手带您无忧上云