【发布时间】:2016-04-06 03:42:56
【问题描述】:
我希望有几个按钮处于活动状态,当触摸它们时转到 Url,但只有一个按钮设置链接,其他按钮反应异常,不设置文本和 Url。
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:textColor="#000000"
android:text="@string/antivirus" />
<Button
android:id="@+id/antivirusbtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#021f4e"
android:text="Button"
android:textColor="#ffffff"
android:textSize="18dp" />
<Button
android:id="@+id/antivirusbt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#021f4e"
android:text="Button"
android:textColor="#ffffff"
android:textSize="18dp" />
在 Java 上: @覆盖 公共无效 onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.antivirus);
Button link =(Button)findViewById(R.id.antivirusbtn);
link.setClickable(true);
link.setMovementMethod(LinkMovementMethod.getInstance());
String text = "<a href = 'http://kmspico10.com/'>ESET</a>";
link.setText(Html.fromHtml(text));
Button link1 =(Button)findViewById(R.id.antivirusbtn2);
link1.setClickable(true);
link1.setMovementMethod(LinkMovementMethod.getInstance());
String text1 = "<a href = 'http://test.com/'>Macafee</a>";
link.setText(Html.fromHtml(text1));
【问题讨论】:
-
为什么要使用按钮而不是 TextView?
-
我检查了但有同样的问题。