Android - set a value of TextView to a custom TextView
<p>I have a custom textview class with this code:</p>

<pre><code>    public CustomTextView extends TextView {

        public CustomTextView(Context c, AttributeSet a) {
            super(c, a);
            TextView tv = (TextView) findViewById(R.id.myTv);
            String str = tv.getText().toString();

            setText(str);
        }
    }
</code></pre>

<p>And my main.xml contains this:</p>

<pre><code>    &lt;TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/myTv"
        android:text="Unkown" /&gt;

    &lt;com.test.CustomTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="100.0sp" /&gt;
</code></pre>

<p>What I want to do is I want to get the string value of the TextView(with ID of myTv) and set the text of my CustomTextView same as the TextView. Something like TextView = CustomTextView.</p>

<p>The string value of myTv is changed by a sharedpreferences so everytime the text changes, the custom text also will change.</p>

<p>My problem is how to do this correctly?</p>