问题:
我有一个自定义适配器listview,目前包含checkbox和edittext。我没有更改res/values/styles文件夹中的任何主题。由于某种原因,checkbox和edittext具有与正常样式/主题(“ AppTheme”)不同的样式/主题。
自动生成的主题:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但是该复选框是白色的,只有选中该复选框才能看到。(颜色不是上面设置的colorAccent),并且edittext具有与选中该复选框时相同的颜色(绿色/蓝色)。
颜色:
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
Run Code Online (Sandbox Code Playgroud)
我尝试了什么?
我尝试使用xml属性android:theme和设置项目容器的主题/样式以及项目本身style。每个都无济于事。
这正常吗?如果是这样,如何更改列表项的样式/主题?如果没有,那可能是错的?
我的listitem.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent" >
<CheckBox
android:id="@+id/cb_listitem"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText
android:id="@+id/editText_listitem"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="9"
android:textColor="@color/black"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
自定义适配器中的getView:
@Override
public View getView(int position, …Run Code Online (Sandbox Code Playgroud)