【发布时间】:2012-02-22 23:36:28
【问题描述】:
我想将按钮 myButton 添加到 TextView。如何将它放在一行中,使其看起来像一组行。这是要添加的文本示例
请在此处按此刷新值集。
我想让“这里”作为可点击按钮。我该怎么做。任何关于它的 sn-p 都会有所帮助。
【问题讨论】:
标签: android button click textview
我想将按钮 myButton 添加到 TextView。如何将它放在一行中,使其看起来像一组行。这是要添加的文本示例
请在此处按此刷新值集。
我想让“这里”作为可点击按钮。我该怎么做。任何关于它的 sn-p 都会有所帮助。
【问题讨论】:
标签: android button click textview
android:background="@null" 将Button 的背景设置为空,并赋予与其他TextView 相同的文本颜色。
或者您可以将 3 个 TextView 和 setOnClickListener 带到中间一个。
【讨论】:
RGB(0, 122, 255),和看起来一样! (Y)
使用无边框android属性设置Button的样式以去除背景和边框:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/borderlessButtonStyle"
android:text="here" />
【讨论】:
制作三个 textView ex:textView1、textView2 和 textView3。
<RelativeLayout android:id="@+id/textLay"
android:layout_width="fill_parent" android:layout_height="wrap_content"
>
<TextView android:id="@+id/textView1" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please press this"/>
<TextView android:id="@+id/textView2" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="here"
android:layout_toRightOf="@+id/textView1" />
<TextView android:id="@+id/textView3" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="to refresh the set of values."
android:layout_toRightOf="@+id/textView2" />
</RelativeLayout>
【讨论】:
只需将以下属性添加到 XML 布局文件中的 TextView 即可使其可点击。
android:clickable="true"
在您的 Java 文件中添加 OnClickListener 以完成对文本视图的点击操作。
【讨论】:
为 XML 中的 TextView 添加 android:clickable="true" 和 android:onClick="yourclickname"。然后在您的活动中定义yourclickname。这应该使您的TextView 可点击并在点击时触发指定的方法。
【讨论】: