我有一个微调器,当活动打开时,它会开始为空。还有一个拍照按钮。图片按钮会打开相机,该相机可以正常工作,然后返回活动时,它将调用google vision,并获取填充微调框的对象的描述(描述列表)。所有这些都有效,但是当微调器打开并选择了某些内容时。微调框不显示您选择的对象,而是保持空白。
编辑(我很确定这与在首次创建活动时微调框为空有关,有人知道对此有修复方法吗?)
微调框如下所示
<Spinner
android:id="@+id/spinnerVisionAPI"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/takePicture"
android:layout_alignStart="@+id/imageView"
android:layout_below="@+id/imageView"
android:textColor="#000000"
android:layout_toStartOf="@+id/takePicture" />
我的代码在onCreate中有这些行
ArrayAdapter<String> dataAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, descriptions);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerVisionAPI.setAdapter(dataAdapter);
spinnerVisionAPI.setOnItemSelectedListener(this);
这是描述列表的填充位置
private String formatAnnotation(List<EntityAnnotation> entityAnnotation) {
String message = "";
if (entityAnnotation != null) {
for (EntityAnnotation entity : entityAnnotation) {
System.out.println(entity.getDescription());
descriptions.add(entity.getDescription());
//
message = message + " " + entity.getDescription() + " " + entity.getScore();
message += "\n";
}
} else {
message = "Nothing Found";
}
return message;
}
为什么在选择了某些内容后,微调框仍然保留为空。