TextView onclick method

  • Replies:3
  • OpenNot stickiedUnanswered
  • Forum posts: 6

Dec 15, 2015 12:46:23 PM via Website

I am trying to develop a textbox which once the user clicks on the textbox it need to direct them to another activity I have tried to use the onclickListener method which crashes the application once clicked on the textbox.

Could you please advise.

forgotpasstxt= (TextView) findViewById(R.id.txtForgotpPass);
        forgotpasstxt.setonclickListener(new View.onclickListener() {
            public void onclick(View view) {
                Intent myIntent = new Intent(view.getContext(), ChangePassword.class);
                startActivityForResult(myIntent, 0);
                finish();
            }

        });
  • Forum posts: 644

Dec 15, 2015 1:46:37 PM via Website

first where are the othere codes? the click handler in xml?, second i will not use finish in the OnClick function.
Also check
android:clickable="true"

Looking for security app? Try Leo Privacy Guard 3.0.

Join Our Christmas Contest by visiting our Facebook page "LEO Privacy Guard"

  • Forum posts: 6

Dec 15, 2015 1:54:26 PM via Website

This is already set to true.

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Forgot Password?"
        android:id="@+id/txtForgotpPass"
        android:clickable="true"
        android:onClick="perform_action"
        android:textColor="#ff3b5998"
        android:layout_below="@+id/btnReset"
        android:layout_centerHorizontal="true" />
Deactivated Account
  • Forum posts: 271

Dec 15, 2015 6:05:59 PM via Website

Thanks for the code mate, helped me a lot.

Looking for security app? Try Leo Privacy Guard 3.0.

Join Our Christmas Contest by visiting our Facebook page LEO Privacy Guard