Je rencontre un problème comprenant une vue Kotlin personnalisée dans un fichier de mise en page XML. Voici le code:"Les classes suivantes sont introuvables" avec la vue Kotlin personnalisée dans la mise en page
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) { ... }
}
et le 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>
Ensuite, la mise en page prévisualiseur se plaint:
« Missing classes-
Les classes suivantes ne pouvait pas être trouvé : com.turingtechnologies.materialscrollbar.CustomView
(Fix Build Path, XML Edition, Créer une classe) »
Note: Ceci est AS 3.0 beta 3
Quel est le comportement d'une version stable d'AS? –
@MaximOstrovidov Je vais regarder et vous faire savoir –
Le code semble bien. Il pourrait juste être quelques retards par AS. Essayez "clean -> rebuild" ou invalidez les caches. –