二进制XML文件第9行:二进制XML文件第9行:错误夸大类<未知>

时间:2018-07-11 02:55:30

标签: android android-recyclerview kotlin android-sqlite recycler-adapter

膨胀版面时出现此错误。我认为发生此错误是因为我的查询代码。因为当我注释代码时,该片段可以正常工作。

这是我认为存在问题的代码:

fun getInvoiceListData(offset:Int, limit:Int): ArrayList<InvoicesCustomerAddressRelationship>
{
    val db = context.database.readableDatabase
    var data: ArrayList<InvoicesCustomerAddressRelationship> = ArrayList()

    var columns = Invoices.TABLE_NAME+"."+Invoices.COLUMN_ID + " AS invoice_id,"
    columns += Invoices.TABLE_NAME+"."+Invoices.COLUMN_CUSTOMER_ID + " AS cus_customer_id,"
    columns += Customer.TABLE_NAME+"."+Customer.COLUMN_NAME + " AS customer_name,"
    columns += Invoices.COLUMN_ADDRESS_ID + " AS address_id,"
    columns += CustomerAddress.TABLE_NAME+"."+CustomerAddress.COLUMN_NAME + " AS address_name,"
    columns += CustomerAddress.TABLE_NAME+"."+CustomerAddress.COLUMN_ADDRESS + ","
    columns += Invoices.COLUMN_TOTAL_BILLING + ","
    columns += Invoices.COLUMN_STATUS + ","
    columns += Invoices.TABLE_NAME+"."+Invoices.COLUMN_CREATED_AT + " as inv_created_at,"
    columns += Customer.TABLE_NAME+"."+Customer.COLUMN_ID + " AS rel_customer_id,"
    columns += CustomerAddress.TABLE_NAME+"."+CustomerAddress.COLUMN_ID + " AS rel_address_id"

    var query = "SELECT " + columns + " FROM " + Invoices.TABLE_NAME
    query += " LEFT JOIN " + Customer.TABLE_NAME + " ON " + "cus_customer_id = rel_customer_id"
    query += " LEFT JOIN " + CustomerAddress.TABLE_NAME + " ON " + "address_id = rel_address_id  ORDER BY invoice_id DESC LIMIT " + offset.toString() + "," + limit.toString()

    val sql:Cursor = db.rawQuery(query, null)

    if(sql.moveToFirst()) {
        do {
            val invoiceId = sql.getString(sql.getColumnIndex("invoice_id"))
            val customerId = sql.getString(sql.getColumnIndex("cus_customer_id"))
            val customerName = sql.getString(sql.getColumnIndex("customer_name"))
            val addressId = sql.getString(sql.getColumnIndex("address_id"))
            val addressName = sql.getString(sql.getColumnIndex("address_name"))
            val address = sql.getString(sql.getColumnIndex(CustomerAddress.COLUMN_ADDRESS))
            val totalBilling = sql.getString(sql.getColumnIndex(Invoices.COLUMN_TOTAL_BILLING))
            val status = sql.getString(sql.getColumnIndex(Invoices.COLUMN_STATUS))
            val createdAt = sql.getString(sql.getColumnIndex("inv_created_at"))

            data.add(InvoicesCustomerAddressRelationship(
                    invoiceId.toInt(),
                    customerId.toInt(),
                    customerName,
                    addressId.toInt(),
                    addressName,
                    address,
                    totalBilling.toInt(),
                    status.toInt(),
                    createdAt)
            )

        }while(sql.moveToNext())
    }

    sql.close()
    db.close()

    return data
}

RVInvoiceListAdapter

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RVInvoiceListAdapter.ViewHolder {
    val context = parent.context
    val inflater = LayoutInflater.from(context)

    // Inflate the custom layout. Log pointing this line is the error
    val contactView = inflater.inflate(R.layout.invoice_list_child, parent, false) 
    // Return a new holder instance
    return ViewHolder(contactView)
}

invoice_list_child布局:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<android.support.constraint.ConstraintLayout
    android:id="@+id/barcodeToPrintChildParent"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_marginBottom="3dp"
    android:layout_marginTop="3dp"
    android:background="@drawable/border_invoice_list"
    app:layout_constraintBottom_toBottomOf="@+id/barcodeText0"
    app:layout_constraintTop_toBottomOf="@+id/barcodeText0">


    <TextView
        android:id="@+id/textView22"
        android:layout_width="wrap_content"
        android:layout_height="20dp"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/border_title"
        android:textColor="@color/colorPrimary"
        android:text="ID: "
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/invoiceId"
        android:layout_width="30dp"
        android:layout_height="20dp"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="0"
        app:layout_constraintStart_toEndOf="@+id/textView22"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/tempInvoiceId"
        android:layout_width="30dp"
        android:layout_height="20dp"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="0"
        android:visibility="invisible" />

    <TextView
        android:id="@+id/textView25"
        android:layout_width="wrap_content"
        android:layout_height="20dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/border_title"
        android:text="Tgl:"
        android:textColor="@color/colorPrimary"
        app:layout_constraintEnd_toStartOf="@+id/date"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/date"
        android:layout_width="110dp"
        android:layout_height="20dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/textView27"
        android:layout_width="wrap_content"
        android:layout_height="20dp"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/border_title"
        android:text="Pembeli:"
        android:textColor="@color/colorPrimary"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView22" />

    <TextView
        android:id="@+id/customerName"
        android:layout_width="115dp"
        android:layout_height="20dp"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintStart_toEndOf="@+id/textView27"
        app:layout_constraintTop_toBottomOf="@+id/invoiceId" />

    <TextView
        android:id="@+id/textView29"
        android:layout_width="wrap_content"
        android:layout_height="20dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/border_title"
        android:text="Total:"
        android:textColor="@color/colorPrimary"
        app:layout_constraintEnd_toStartOf="@+id/total"
        app:layout_constraintTop_toBottomOf="@+id/textView33" />

    <TextView
        android:id="@+id/total"
        android:layout_width="110dp"
        android:layout_height="20dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:text="0"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/status" />

    <TextView
        android:id="@+id/textView31"
        android:layout_width="wrap_content"
        android:layout_height="20dp"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/border_title"
        android:text="Alamat:"
        android:textColor="@color/colorPrimary"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView27" />

    <TextView
        android:id="@+id/address"
        android:layout_width="wrap_content"
        android:layout_height="20dp"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintStart_toEndOf="@+id/textView31"
        app:layout_constraintTop_toBottomOf="@+id/customerName" />

    <TextView
        android:id="@+id/textView33"
        android:layout_width="wrap_content"
        android:layout_height="20dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/border_title"
        android:text="Status:"
        android:textColor="@color/colorPrimary"
        app:layout_constraintEnd_toStartOf="@+id/status"
        app:layout_constraintTop_toBottomOf="@+id/textView25" />

    <TextView
        android:id="@+id/status"
        android:layout_width="110dp"
        android:layout_height="20dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:text="0"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/date" />
</android.support.constraint.ConstraintLayout>

我在Logcat中找不到任何与错误相关的查询。我只发现此错误:

android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class <unknown>
    at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    at com.mockie.daikokuten.adapters.RVInvoiceListAdapter.onCreateViewHolder(RVInvoiceListAdapter.kt:87)
    at com.mockie.daikokuten.adapters.RVInvoiceListAdapter.onCreateViewHolder(RVInvoiceListAdapter.kt:29)
    at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6493)
    at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5680)
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5563)
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5559)
    at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2229)
    at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1556)

0 个答案:

没有答案