Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将“TextView”的可见性绑定到“EditText”-Android的文本属性_Android_Xml_Android Layout_Binding - Fatal编程技术网

将“TextView”的可见性绑定到“EditText”-Android的文本属性

将“TextView”的可见性绑定到“EditText”-Android的文本属性,android,xml,android-layout,binding,Android,Xml,Android Layout,Binding,noobieDeveloper 我有一个EditText和TextView,如图所示 <LinearLayout android:gravity="center" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.2"&

noobieDeveloper

我有一个EditText和TextView,如图所示

<LinearLayout
        android:gravity="center"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.2">
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/editLength"
            android:hint="LENGTH"
            android:layout_gravity="center_horizontal|center_vertical"
            android:background="@android:color/transparent"
            android:textSize="40dp"
            android:textAlignment="center"
            android:textColor="#ffffff"
            android:textColorHint="#ffffff" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="40dp"
            android:visibility="invisible"
            android:textColor="#ffffff"
            android:text="min"/>
    </LinearLayout>
我想要实现的是,当我编辑“editLength”控件时,我希望TextView可见

我不希望它与glue codeActivity.java有关。 我想这可以通过将textbox的visibility属性绑定到“EditText”的文本来实现

有谁能指导我如何做到这一点吗?

你应该使用。它用于在用户输入数据时监视EditText内容。它允许您在EditText中输入时跟踪每个字符

范例


阅读

但这是通过代码实现的。我希望在xml文件本身中绑定可见性属性。我来自WPF的背景,我认为它在本地android中不可能实现。
         EditText inputObj = (EditText)findViewById(R.id.your_id);
         TextView   outputObj = (TextView)findViewById(R.id.your_id2);
         inputObj .addTextChangedListener(watch);

        }
 // End Oncreate

       TextWatcher watch = new TextWatcher(){

        @Override
        public void afterTextChanged(Editable arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                int arg3) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onTextChanged(CharSequence s, int a, int b, int c) {
            // TODO Auto-generated method stub

            // Add code here //VISIBLE//GONE
        }};