在xml中:
<TextView android:id="@+id/textView_regtext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@+id/editText_password" android:layout_below="@+id/editText_password" android:layout_marginRight="15dp" android:layout_marginTop="26dp" android:onClick="clickHandler_reg" android:clickable="true" android:text="注册用户" />
添加点击监听事件:android:onClick="clickHandler_reg"
特别注意需要添加:android:clickable="true",否则无法点击文本
在Java中添加点击函数
public void clickHandler_reg(View view) { Intent intent=new Intent(this,RegActivity.class); //跳转 LogActivity.this.startActivity(intent); }
按钮bottom也可类似处理,添加点击处理事件。
textview添加下划线:
tv = (TextView)findViewById(R.id.textView_regtext); tv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); tv.getPaint().setAntiAlias(true);