我试图 在我的Kotlin项目中使用Android DataBinding库设置自定义属性,如下所示:
<ImageView
android:id="@+id/imgView”
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
app:imageUrl="@{segment.url}"/>
Run Code Online (Sandbox Code Playgroud)
class Utils {
companion object {
@BindingAdapter("bind:imageUrl")
@JvmStatic
fun loadImage(view: ImageView, url:String)
{Picasso.with(view.context).load(url).error(R.drawable.error).into(view)}
}
Run Code Online (Sandbox Code Playgroud)
我得到的运行时错误是:
in中的BindingAdapter不是静态的,需要使用从DataBindingComponent检索的对象.如果不使用带有DataBindingComponent的通胀方法,请使用DataBindingUtil.setDefaultComponent或使所有BindingAdapter方法保持静态.
任何解决它的指针?
这仅适用于自定义属性.其余的数据绑定工作正常
我正在尝试使用合流客户端注册表中的 avro 模式从 kafka avro 主题读取数据。我正在使用io.confluent库版本5.4.1。这是 gradle 文件中的条目
compile (group: 'io.confluent', name: 'kafka-avro-serializer', version: '5.4.1') {
exclude group: 'org.apache.avro', module: 'avro'
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误。
Caused by: io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: Unauthorized; error code: 401
Run Code Online (Sandbox Code Playgroud)
public PCollection<KV<String, GenericRecord>> apply(Pipeline p) {
ConfluentSchemaRegistryDeserializerProvider<GenericRecord> valDeserializerProvider =
ConfluentSchemaRegistryDeserializerProvider.of(params.schemaUrl, "topic-value");
PCollection<KafkaRecord<String, GenericRecord>> records = p.apply("GetDataFromKafka", KafkaIO.<String, GenericRecord>read()
.withBootstrapServers(params.apiHost)
.withTopics("topic")
.withConsumerConfigUpdates(params.getConsumerProps())
.withKeyDeserializer(StringDeserializer.class)
.withValueDeserializer(valDeserializerProvider)
.commitOffsetsInFinalize());
return records.apply("TopicAndDataInput", MapElements.via(new SimpleFunction<KafkaRecord<String, GenericRecord>, KV<String, GenericRecord>>() {
@Override
public KV<String, GenericRecord> apply(KafkaRecord<String, GenericRecord> input) {
String topic = input.getTopic();
GenericRecord data …Run Code Online (Sandbox Code Playgroud)