亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android給TextView添加點(diǎn)擊事件的實(shí)現(xiàn)方法

 更新時(shí)間:2016年12月17日 15:30:18   投稿:jingxian  
下面小編就為大家?guī)硪黄狝ndroid給TextView添加點(diǎn)擊事件的實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

首先設(shè)定TextView的clickable屬性為true。

可以在布局文件中進(jìn)行設(shè)定,比如:

<TextView

      android:id="@+id/phone"

      android:clickable="true" --------->設(shè)定此屬性

      android:layout_marginLeft="10dp"

      android:layout_below="@id/address"

      android:layout_toRightOf="@id/avatar"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:layout_marginTop="10dp"

      android:text="18764563523"

      android:textColor="@color/white" />

也可以在java代碼中設(shè)定:

textView.setClickable(true);

然后綁定事件回調(diào)函數(shù):

textView.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View arg0) {

//調(diào)到撥號界面

Uri uri = Uri.parse("tel:18764563501");  

Intent intent = new Intent(Intent.ACTION_DIAL, uri);   

startActivity(intent);

}

});

 完成TextView的點(diǎn)擊事件綁定!

以上就是小編為大家?guī)淼腁ndroid給TextView添加點(diǎn)擊事件的實(shí)現(xiàn)方法全部內(nèi)容了,希望大家多多支持腳本之家~

相關(guān)文章

最新評論