设置TaxtView的监听

来源:互联网 发布:淘宝商城行车记录仪 编辑:程序博客网 时间:2024/06/08 16:18

设置 TextView 监听

只要在textview中添加

android:clickable="true"
例如:

<span style="font-family:KaiTi_GB2312;font-size:18px;"><TextView        android:id="@+id/tv_notice_right_txt"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        <strong><span style="color:#33cc00;background-color: rgb(255, 153, 255);">android:clickable="true"</span></strong>        android:textSize="20sp"        android:layout_alignParentRight="true"        android:layout_marginRight="10dp"        android:layout_centerVertical="true"        android:textColor="@android:color/white" /></span>
<span style="font-family:KaiTi_GB2312;font-size:18px;"></span>
然后在java代码里实现监听即可:

<span style="font-family:KaiTi_GB2312;font-size:18px;"> title_rigt_txt = (TextView) findViewById(R.id.tv_notice_right_txt); title_rigt_txt.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                Intent intent = new Intent(NoticeActivity.this,NoticeEditActivity.class);                startActivity(intent);            }        });</span>


 

0 0
原创粉丝点击