【发布时间】:2015-12-15 15:38:46
【问题描述】:
我有一个带有 OnClick 方法的 textView 来导航另一个活动。但是,如果我按下该文本,它不会导航。但如果我使用 Button 而不是 TextView,它会完美运行。 TextView 不能使用 OnClick 方法?
forgotpasstxt= (TextView) findViewById(R.id.txtForgotpPass);
/** Textview on click even.
*
*/
forgotpasstxt.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), ChangePassword.class);
startActivityForResult(myIntent, 0);}
});
XML.登录
<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" />
请帮忙,我不明白为什么一旦用户点击忘记密码的链接,应用程序就会崩溃。
【问题讨论】: