-1

I would like to access a clickable textview in my Java Code, to make it act like a hyperlink or <a> in html.

<TextView
    android:id="@+id/register"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:text="@string/signUp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toEndOf="@+id/textView"
    app:layout_constraintTop_toBottomOf="@+id/loginBtn"
    app:layout_constraintVertical_bias="0.424" />

The above is my XML of the textview.

Zoe
  • 27,060
  • 21
  • 118
  • 148
  • @rajan.kali please don't abuse code formatting like that. Inline code is NOT meant for names or highlighting stuff – Zoe Feb 07 '21 at 13:01

2 Answers2

-1

You can save your TextView in a variable, I've also changed it's text.

TextView register = (TextView)findViewById(R.id.register);
register.setText("newText");
Cristian
  • 59
  • 6
-1

you can use setOnClickListener

TextView textView=(TextView)findViewById(R.id.registrar);
    textView.setOnclickListener(new View.OnclickListener(){
            @Override
            void onclick(View v){
                   // body 
}
});