我试图在Kotlin中重用以下Java代码:
SimpleCursorAdapter scAdapter = new SimpleCursorAdapter(this,
R.layout.textsummarylistentry, mMatrixCursor,
from, to);
setListAdapter(scAdapter);
当我将其复制并粘贴到扩展ListActivity的Kotlin类中,并接受Android Studio对Kotlin的自动转换时,我得到以下结果:
var scAdapter : android . widget . SimpleCursorAdapter ? =
SimpleCursorAdapter(
this,
R.layout.textsummarylistentry, mMatrixCursor,
from, to
)
listAdapter = scAdapter
Quick Fix无法解决许多错误。 我应该如何更正这段代码?
我想这应该管用:
var scAdapter = SimpleCursorAdapter(this, R.layout.textsummarylistentry, mMatrixCursor, from, to)
setListAdapter(scAdapter)
如果不起作用,请共享错误消息。