androidbroadcast / ViewBindingPropertyDelegate

Make work with Android View Binding simpler
https://proandroiddev.com/make-android-view-binding-great-with-kotlin-b71dd9c87719
Apache License 2.0
1.42k stars 102 forks source link

how to use 'noreflection:1.5.6' in this case? #118

Closed VayneKaso closed 7 months ago

VayneKaso commented 1 year ago
class USBDebugLayout(context: Context?, attrs: AttributeSet?) : ScrollView(context, attrs) {
    var count = 0
    var tvText: TextView? = null

    init {
        LayoutInflater.from(context).inflate(R.layout.layout_usb_connect, this)
        val btnTest = this.findViewById<Button>(R.id.btn_test)
        tvText = this.findViewById<TextView>(R.id.tv_test)
        btnTest.setOnClickListener(OnClickListener {
            count++
            btnTest.text = "" + count + "次点击"
        })
    }

    fun getView(): TextView? {
        return tvText
    }
}

I try a lot of times and result all is failed

VayneKaso commented 1 year ago

Who got the success in this case ? help me edit it ,plz

VayneKaso commented 1 year ago
<?xml version="1.0" encoding="utf-8"?>
<merge 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">

    <LinearLayout
        android:id="@+id/fl_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:orientation="vertical">

        <Button
            android:id="@+id/btn_test"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Clear Log" />

        <TextView
            android:id="@+id/tv_test"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textColor="@color/mainBlue"
            android:textStyle="bold" />
    </LinearLayout>
</merge> 

I use merge as root element,Perhaps because of this cause failure?

kirich1409 commented 1 year ago

Did you try the same way like in my sample?