如何复制默认的单选按钮样式
how to copy default radiobuttonstyle
我正在使用以下代码以编程方式创建单选按钮:
new RadioButton(getActivity());
但是,以这种方式创建的这些单选按钮看起来不像从 xml 文件创建的默认单选按钮。
如何复制默认的单选按钮样式?
我也试过下面的格式,还是不行。
new RadioButton(getActivity(), null, com.android.internal.R.attr.radioButtonStyle);
我收到以下错误:
Error:(147, 81) error: package com.android.internal.R does not exist Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
有什么建议吗?
假设您正在使用 AppCompatActivity
,您应该使用 AppCompatRadioButton 以编程方式创建一个默认样式为 AppCompat 的 RadioButton。
我正在使用以下代码以编程方式创建单选按钮:
new RadioButton(getActivity());
但是,以这种方式创建的这些单选按钮看起来不像从 xml 文件创建的默认单选按钮。
如何复制默认的单选按钮样式?
我也试过下面的格式,还是不行。
new RadioButton(getActivity(), null, com.android.internal.R.attr.radioButtonStyle);
我收到以下错误:
Error:(147, 81) error: package com.android.internal.R does not exist Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
有什么建议吗?
假设您正在使用 AppCompatActivity
,您应该使用 AppCompatRadioButton 以编程方式创建一个默认样式为 AppCompat 的 RadioButton。