
我对Android很新,我有些疑惑.
我有一个TextVIEw:
<TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="Go Back" />为什么我要把文字Go Back看起来像可点击的?我问的是外观和感觉. TextVIEw应该像button一样可以显示.
提前致谢.
解决方法:
在你的drawable文件夹中创建一个名为“mybutton.xml”的xml文件并写下:
<?xml version="1.0" enCoding="utf-8"?><selector xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:dither="true"> <item androID:state_pressed="true" androID:drawable="@drawable/mybutton2"/> <item androID:drawable="@drawable/mybutton1"/></selector>然后将两个png添加到drawables文件夹中…… mybutton1.png,mybutton2.png.
所以你的按钮有两种不同的状态.
现在将背景设置为textvIEw:
androID:background="@drawable/mybutton"那么,在你的代码中你必须设置一个clickListener:
findVIEwByID(R.ID.mytextvIEw).setonClickListener(new OnClickListener(){ @OverrIDe public voID onClick(VIEw v) { //your code goes here }});这就是全部……您也可以使用形状而不是图像.
总结以上是内存溢出为你收集整理的看看TextView可点击,Android?全部内容,希望文章能够帮你解决看看TextView可点击,Android?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)