【发布时间】:2017-08-27 20:27:39
【问题描述】:
我遇到了一个问题,包括 XML 布局文件中的自定义 Kotlin 视图。代码如下:
class CustomView: RelativeLayout {
/**
* Programmatic constructor
*/
constructor(aVariable: Boolean, context: Context): super(context) { ... }
/**
* XML constructor
*/
@JvmOverloads
constructor(context: Context, attributeSet: AttributeSet? = null, defStyle: Int = 0): super(context, attributeSet, defStyle) { ... }
}
和XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.turingtechnologies.materialscrollbar.CustomView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
然后布局预览器报错:
“缺课-
找不到以下类:
com.turingtechnologies.materialscrollbar.CustomView(修复构建路径,编辑 XML,创建类)"
注意:这是 AS 3.0 beta 3
【问题讨论】:
-
稳定的 AS 版本的行为是什么?
-
@MaximOstrovidov 我会看看并告诉你
-
代码看起来不错。可能只是 AS 的一些滞后。尝试“清理 -> 重建”或使缓存无效。
-
@GeorgySavatkov 我都做过
标签: android android-studio kotlin android-custom-view