英文:
Cannot find Kotlin class using Java instantiation
问题
我有这个Kotlin类:
package com.example.project
class BasketAdapter(val context: Context) : BaseAdapter() {
...
}
当我尝试在我的Java代码中实例化时,我总是得到"error: cannot find symbol"错误。这是我在Java中尝试实例化类的方式:
package com.example.project
...
public class BasketFragment extends Fragment {
...
BasketAdapter adapter = new BasketAdapter(requireContext());
binding.listviewItems.setAdapter(adapter);
...
}
有人能解释一下问题吗?
英文:
I have this Kotlin class:
package com.example.project
class BasketAdapter(val context: Context) : BaseAdapter() {
...
}
When I try to instantiate from my Java code, I always get "error: cannot find symbol". This is how I try to instantiate the class in Java:
package com.example.project
...
public class BasketFragment extends Fragment {
...
BasketAdapter adapter = new BasketAdapter(requireContext());
binding.listviewItems.setAdapter(adapter);
...
}
Can someone explain the issue?
答案1
得分: 0
我没有找到任何解决方案。最后我将我的适配器类转换成了Java代码。
英文:
I did not find any resolution. I ended up converting my Adapter class to Java code.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论