Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 2025
Alex Hales
  • 0
Alex HalesTeacher
Asked: May 31, 20222022-05-31T11:39:14+00:00 2022-05-31T11:39:14+00:00

json – how I can use data class in layout?

  • 0

[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&#8221;
xmlns:app=”http://schemas.android.com/apk/res-auto&#8221;
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]

  • 0 0 Answers
  • 11 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 4796 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 1063 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 1009 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.