开发者

passing click event to underlying view

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜