[ad_1]
I have turned json data into classes in my app to use them in layout files.this is my Davaproperty class:
class DavaProperty : ArrayList<DavaProperty.DavaPropertyItem>(){
data class DavaPropertyItem(
val _links: Links,
val attributes: List<Any>,
val average_rating: String,
val backordered: Boolean,
val backorders: String,
val backorders_allowed: Boolean,
val button_text: String,
val catalog_visibility: String,
val categories: List<Category>,
val cross_sell_ids: List<Any>,
val date_created: String,
val date_created_gmt: String,
val date_modified: String,
val date_modified_gmt: String,
val date_on_sale_from: Any,
val date_on_sale_from_gmt: Any,
val date_on_sale_to: Any,
val date_on_sale_to_gmt: Any,
val default_attributes: List<Any>,
val description: String,
val dimensions: Dimensions,
val download_expiry: Int,
val download_limit: Int,
val downloadable: Boolean,
val downloads: List<Any>,
val external_url: String,
val featured: Boolean,
val grouped_products: List<Any>,
val has_options: Boolean,
val id: Int,
val images: List<Image>,
val low_stock_amount: Any,
val manage_stock: Boolean,
val menu_order: Int,
val meta_data: List<MetaData>,
val name: String,
val on_sale: Boolean,
val parent_id: Int,
val permalink: String,
val price: String,
val price_html: String,
val purchasable: Boolean,
val purchase_note: String,
val rating_count: Int,
val regular_price: String,
val related_ids: List<Int>,
val reviews_allowed: Boolean,
val sale_price: String,
val shipping_class: String,
val shipping_class_id: Int,
val shipping_required: Boolean,
val shipping_taxable: Boolean,
val short_description: String,
val sku: String,
val slug: String,
val sold_individually: Boolean,
val status: String,
val stock_quantity: Any,
val stock_status: String,
val tags: List<Any>,
val tax_class: String,
val tax_status: String,
val total_sales: Int,
val type: String,
val upsell_ids: List<Any>,
val variations: List<Any>,
val virtual: Boolean,
val weight: String
) {
data class Links(
val collection: List<Collection>,
val self: List<Self>
) {
data class Collection(
val href: String
)
data class Self(
val href: String
)
}
data class Category(
val id: Int,
val name: String,
val slug: String
)
data class Dimensions(
val height: String,
val length: String,
val width: String
)
data class Image(
val alt: String,
val date_created: String,
val date_created_gmt: String,
val date_modified: String,
val date_modified_gmt: String,
val id: Int,
val name: String,
val src: String
)
data class MetaData(
val id: Int,
val key: String,
val value: Any
)
}
}
and this is my item_view.xml that I have to associate items to classes:
when I run the program, it gives me this error:
Could not find accessor com.example.android.davadoctor.network.DavaProperty.DavaPropertyItem
please tell me where I have to correct?`
<layout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:app=”http://schemas.android.com/apk/res-auto”
variable name=”property” type=”com.example.android.davadoctor.network.DavaProperty”
<ImageView
android:id="@+id/dava_image"
android:layout_width="match_parent"
android:layout_height="150dp"
android:scaleType="centerCrop"
app:imageUrl="@{property.DavaPropertyItem.Image.src}"
android:contentDescription="@null"
android:padding="3dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
>
<TextView
android:id="@+id/price_amount"
android:layout_width="60dp"
android:layout_height="20dp"
android:text="@{Double.toString(property.DavaPropertyItem.price)}"/>
<TextView
android:id="@+id/price_lable"
android:layout_width="60dp"
android:layout_height="20dp"
android:text="@string/price_lable"/>
<TextView
android:id="@+id/title"
android:layout_width="100dp"
android:layout_height="20dp"
android:text="@{property.DavaPropertyItem.name}"/>
</LinearLayout>
`
[ad_2]