Hi guys. I'm trying to avoid the call to `requestR...
# android
b
Hi guys. I'm trying to avoid the call to
requestRowsLayout
whenever a new row is added.
Copy code
TableLayout.java

public void addView(View child) {
    super.addView(child);
    requestRowsLayout();
}

public void requestLayout() {
        if (mInitialized) {
            int count = getChildCount();
            for (int i = 0; i < count; i++) {
                getChildAt(i).forceLayout();
            }
        }

        super.requestLayout();
}
I've tried to use reflection to set
mInitialized
= false. But cannot found the variable via reflection. Can you give me advise. ?
K 1
not kotlin but kotlin colored 6
1
c
This is a workspace for the Kotlin programming language and you dare to post java code 😅. Better ask your question on a different platform. You can find some resources in the channel description.
b
Nope bro. What i'm asking about Kotlin. Just about the source I trying to getting the variable is Java 😄
c
still not a question to ask here. It’s not related to Kotlin but Android.
b
Why a question about Kotlin reflection to access a field in Java class is not a sort of Kotlin question 😕
c
then rephrase your question I guess - for me you posted Java code and wanted to “hack” a layout in the Android SDK.
Long story short. The code might not be the same on each Manufacturer and SDK version. so it’s not save to try to do what you want to do.
and that might be the reason you do not “find” the variable via reflection.
b
By using
Copy code
TableLayout::class.declaredMemberProperties
we gonna get all the declare fields of a class right ? But what I'm getting is empty list. Might be the sdk not the same, but always variable existed
c
yes.
and it’s empty on android SDK 33 i.e but not on Android SDK 26.
Copy code
var android.widget.TableLayout.mCollapsedColumns: android.util.SparseBooleanArray!, var android.widget.TableLayout.mInitialized: kotlin.Boolean, var android.widget.TableLayout.mMaxWidths: kotlin.IntArray!, var android.widget.TableLayout.mPassThroughListener: android.widget.TableLayout.PassThroughHierarchyChangeListener!, var android.widget.TableLayout.mShrinkAllColumns: kotlin.Boolean, var android.widget.TableLayout.mShrinkableColumns: android.util.SparseBooleanArray!, var android.widget.TableLayout.mStretchAllColumns: kotlin.Boolean, var android.widget.TableLayout.mStretchableColumns: android.util.SparseBooleanArray!
🙌 1
b
Do you got any idea on that ? If the SDK has some updated, the variable name could be change right ? But I believe that TableLayout will always contain variable inside
Maybe the sdk bug ?
c
Not sure - again, this is a workspace for Kotlin programming language - to find experts on Android, you’d better ask somewhere else.
1
b
ok Thank you.
👍 1