【问题标题】:Compilation error when trying to set autoCompleteTextView adapter to null in ant build尝试在 ant 构建中将 autoCompleteTextView 适配器设置为 null 时出现编译错误
【发布时间】:2012-11-21 15:16:26
【问题描述】:

我正在尝试使用 ant Everything 构建一个 apk,但编译失败并显示以下错误消息:

[javac]  type parameters of <T>void cannot be determined; no unique maximal instance exists for type variable T with upper bounds android.widget.ListAdapter,android.widget.Filterable
[javac]             currentAddressTextView.setAdapter(null);

在 eclipse 中它编译得很好,当我删除这部分代码时,它在 ant 构建期间也能编译。

【问题讨论】:

    标签: android ant android-build


    【解决方案1】:

    你可以试试下面:

         ArrayAdapter<String> adapter = null;
         currentAddressTextView.setAdapter(adapter);
    

    【讨论】:

    • 是的,我会尝试,但即使 adapter.clear() 也不能正常工作。
    • @themilkman:当适配器为空时,adapter.clear() 将如何工作?
    • 我的意思是不要调用 setAdapter(null);只需调用 adapter.clear();
    • @themilkman:clear 的行为与移除适配器本身不同(设置为 null)。通过将适配器设置为空,我不确定您的目的。您使用的是哪个适配器,调用clear() 时遇到什么错误?可以分享一下相关的代码片段吗?
    • 好吧,空的“技巧”奏效了,它是一个 ArrayAdapter。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多