android - 智能手机上没有复选标记的 Android 复选框(模拟器正在工作)
问题描述
我有一些无法正常工作的复选框。复选框结果已选中,但没有复选标记。如果单击复选框两次,将出现复选标记。在模拟器上没有问题,但在我的 Galaxy S7 (Oreo) 上有这个错误。从 db 加载数据后,以编程方式检查复选框:
@Override
protected void onPostExecute(Boolean successo) {
pbGestioneProfilo.setVisibility(View.GONE);
if (successo) {
passioniET.setText(passioni);
libriET.setText(libri);
filmserieET.setText(filmserie);
negoziET.setText(negozi);
tecnologiaCB.setChecked(tecnologia.equals(Utils.TRUE) ? true : false);
sportCB.setChecked(sport.equals(Utils.TRUE) ? true : false);
viaggiCB.setChecked(viaggi.equals(Utils.TRUE) ? true : false);
casacucinaCB.setChecked(casacucina.equals(Utils.TRUE) ? true : false);
abbigliamentoCB.setChecked(abbigliamento.equals(Utils.TRUE) ? true : false);
if (!urlProfilo.equals("")) {
Glide.with(getContext())
.load(urlProfilo)
.into(imgprofilo);
}
} else {
Log.d("MYTAG","ERROR");
Toast.makeText(getContext(),"Error",Toast.LENGTH_SHORT).show();
}
}
在 xml 上:
<ScrollView
android:background="@drawable/backgroundtab"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fbutton="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
...
<CheckBox
android:id="@+id/tecnologiaCB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:text="Tecnologia"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/interessiTV" />
<CheckBox
android:id="@+id/sportCB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:text="Sport"
app:layout_constraintBaseline_toBaselineOf="@+id/tecnologiaCB"
app:layout_constraintStart_toEndOf="@+id/tecnologiaCB" />
<CheckBox
android:id="@+id/viaggiCB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:text="Viaggi"
app:layout_constraintBaseline_toBaselineOf="@+id/tecnologiaCB"
app:layout_constraintStart_toEndOf="@+id/sportCB" />
<CheckBox
android:id="@+id/casacucinaCB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Casa e Cucina"
app:layout_constraintStart_toStartOf="@+id/tecnologiaCB"
app:layout_constraintTop_toBottomOf="@+id/tecnologiaCB" />
<CheckBox
android:id="@+id/abbigliamentoCB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Abbigliamento"
app:layout_constraintBaseline_toBaselineOf="@+id/casacucinaCB"
app:layout_constraintStart_toStartOf="@+id/sportCB" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
有可能修复吗?谢谢
解决方案
推荐阅读
- python - 如何删除以 python 3 中特定元素开头的子列表?
- java - 检索当前用户的孩子数据:Firebase
- c# - Outputting 'SUB' character in CSV file when mapping from XML in XSLT map
- php - FORM 不提交任何东西
- aws-lambda - DynamoDB:更新前删除项目
- python - 有什么方法可以在另一个脚本上使用在不同 python 脚本中创建的数据框?
- unicode - 使用 presto sql 和 AWS athena 中的编码将 varbinary 转换为 varchar
- mediawiki - 从服务器加载数据时出错:apierror-visualeditor-docserver-http-error: (curl error: 7)
- javascript - Angular7:在饼图工具提示上显示数据,而不是使用 MDBootstrap 将鼠标悬停在上面
- java - 性能 - 如何有效地使用 Java 8 来提高性能?