Tencent / QMUI_Android

提高 Android UI 开发效率的 UI 库
http://qmuiteam.com/android
Other
14.4k stars 2.67k forks source link

组合控件中包含EditText 时,跳转startfragment 回来,EditText中文本消失 #1146

Closed Ramblerchris closed 1 year ago

Ramblerchris commented 1 year ago

运行环境

具体问题描述

继承QMUIFragment后 ,组合控件中包含EditText 时,跳转startfragment 回来,EditText中显示文本消失,非组合控件没问题。 直接继承fragment 或在activity中没问题 代码如下:

public class TestView extends FrameLayout {

    public TestView(@NonNull Context context) {
        super(context);
        init(context, null);
    }

    public TestView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    public TestView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs);
    }

    private void init(Context context, AttributeSet attrs) {
        LayoutInflater.from(context).inflate(R.layout.item_dash_testedit, this, true);
    }
}

item_dash_testedit 布局:

<?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">

    <EditText
        android:id="@+id/et_input"
        android:layout_width="match_parent"
        android:layout_height="40dp" />

</LinearLayout>

异常日志(堆栈)