开发者

passing click event to underlying view

开发者 https://www.devze.com 2023-01-29 07:24 出处:网络
I have a Layout with a TextView. The TextView has android:autoLink=\"all\" How can I achieve the following:

I have a Layout with a TextView. The TextView has

android:autoLink="all" 

How can I achieve the following:

  • if user clicks a link, an action associated with that link is exe开发者_高级运维cuted (i.e., click on phone number invokes dialer, etc.)
  • if user clicks anywhere else within Layout boundaries, Layout's onClick is called.

Thanks.


Attach an oclicklistener to the TextBox layout, and handle it from there.

TextView txt = (TextView) findViewById(R.id.yourTextBoxId));  
txt.setOnClickListener(new OnClickListener() {     
                public void onClick(View view) {  

                  // USer Clicked the textBox  

                } 
       });  

The same apply for the Layout, find it and ...

     layout.setOnClickListener(new OnClickListener() {     
                public void onClick(View view) {  

                  // USer Clicked the layout  

                } 
       });  

I hope it helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消